GoLang Naming Rules and Conventions
Nov 8 · 1 min read
The Go project stress a lot on simplicity and readability, hence it adopts some simple convention to ensure that source codes are maintainable.

You must have already seen some of this in the Go Tutorial and Effective Go. This article lists only itemize some well known conventions in writing your Go project.
Files
- Go follows a convention where source files are all lower case with 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.goare only compiled and run by thego testtool.
Functions and Methods
Use camel case, exported functions should start with uppercase:
writeToDB // unexported, only visible within the packageWriteToDB // exported, visible within the package
Constants
Constant should use all capital letters and use underscore _ to separate words.
Variables
- Generally, use relatively simple (short) name.
- Consistent naming style should be used the entire source code
user to u
userID to uid
- If variable type is
bool, its name should start withHas,Is,CanorAllow, etc. - Single letter represents index:
i, j, k
Dave has an excellent article on wriing good and quality Go
