I am new to Go - so this is not an expert advice. But I do it by creating multiple packages where more than one file belong to a particular package. You may already know that in Go lang if multiple files use the same package directive, the code across all the files are combined and treated as a giant code block. For example, if I am creating a blogging app then I'll have a package called adminpanel which comprises of files editor.go, publisher.go, moderation.go etc. So, a particular code in editor.go can access a function from publisher.go.
This is what I usually follow, but I would love to know what you guys use.
Yes and no. Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy. The concept of “interface” in Go provides a different approach that we believe is easy to use and in some ways more general. There are also ways to embed types in other types to provide something analogous—but not identical—to subclassing. Moreover, methods in Go are more general than in C++ or Java: they can be defined for any sort of data, even built-in types such as plain, “unboxed” integers. They are not restricted to structs (classes).
Also, the lack of a type hierarchy makes “objects” in Go feel much more lightweight than in languages such as C++ or Java." - According to GoDoc. And It's not a scripting language, It's something like modern day C, and a Systems/General Purpose programming language.
Alfie Campbell
The CSS guy!
I am new to Go - so this is not an expert advice. But I do it by creating multiple packages where more than one file belong to a particular package. You may already know that in Go lang if multiple files use the same package directive, the code across all the files are combined and treated as a giant code block. For example, if I am creating a blogging app then I'll have a package called
adminpanelwhich comprises of fileseditor.go,publisher.go,moderation.goetc. So, a particular code ineditor.gocan access a function frompublisher.go.This is what I usually follow, but I would love to know what you guys use.