I'm starting in the programming with Go and I want to ask if there are some patterns to follow when programming, like:
// Package
// Structs orderer by importance
// Struct methods
// Un-exported methods
// Exported methods
// getters and setters
There is no specific guideline for this and even stdlib packages does not follow the same way. But as a rule of thumb you should:
godoc
and can read it from top to bottom with understanding, then your order is probably correct :)When in doubt, check some popular stdlib packages, like https://golang.org/src/net/http/server.go.
Other useful code style guidelines can be found here:
The two sources of good style in go are these two documents:
I would also recommend to use these tools for your code base: