Variables
a common abbreviation used in go
using fewer letters in smaller scopes helps with readability from the GO point of view, but instead using the complete words in larger scopes
- use mixedCap
- use all capitals for acronyms like API also
userID
touid
- If the variable type is
bool
, its name should start withHas
,Is
,Can
orAllow
, etc. - don’t use underscore separating for var naming
Functions and Methods
- Use camel case, exported functions should start with uppercase:
Constants
- Constant should use all capital letters and use underscore
_
to separate words.
Files
- Go follows a convention where source files are all lower case with an underscore separating multiple words
- Compound file names are separated with
- File names that begin with “.” or “” are ignored by the go tool
- Files with the suffix
_test.go
are only compiled and run by thego test
tool.