commons
- Long names don't automatically make things more readable.
A helpful doc comment
can often be more valuable than an extra long name.
- Camel case rather than underscores to write multiword names
- No semicolons. The lexer uses a simple rule to insert semicolons automatically as it scans. Go programs have semicolons only in places such as for loop clauses, to separate the initializer, condition, and continuation elements.
packages
- Packages are given lower case, single-word names; there should be no need for underscores or mixedCaps
- The package name is only the default name for imports; it need not be unique across all source code, and in the rare case of a collision the importing package can choose a different name to use locally.
- The package name is the base name of its source directory; the package in
src/encoding/base64
is imported as "encoding/base64" but has name base64, not encoding_base64.
getter & setters
- Getter: If you have a field called owner (lower case, unexported), the getter method should be called Owner (upper case, exported), not GetOwner.
- Setter: A setter function, if needed, will likely be called SetOwner.
interfaces
- By convention, one-method interfaces are named by the method name plus an -er suffix or similar modification to construct an agent noun: Reader, Writer, Formatter, CloseNotifier etc.
- If your type implements a method with the same meaning as a method on a well-known type, give it the same name and signature; call your string-converter method String not ToString. Unless, do not.