-
Know and avoid Go landmines
-
Comment your code.
- Go's commenting conventions
- If reviewers ask questions about why the code is the way it is, that's a sign that comments might be helpful.
-
Command-line flags should use dashes, not underscores
-
Naming
- Please consider package name when selecting an interface name, and avoid redundancy. e.g.:
storage.Interface
is better thanstorage.StorageInterface
. - These articles will explain how to organize your Go packages:
- Do not use uppercase characters, underscores, or dashes in package names.
- Please consider parent directory name when choosing a package name.
- protocols/ethereum/foo.go should say
package ethereum
notpackage protocolsethereum
. - Unless there's a good reason, the
package ethereum
line should match the name of the directory in which the .go file exists. - Importers can use a different name if they need to disambiguate.
- Properties or functions that return an objects type should use the word
kind
orKind
.
- Please consider package name when selecting an interface name, and avoid redundancy. e.g.:
-
Locks
- Locks should be called
lock
and should never be embedded (alwayslock sync.Mutex
). - When multiple locks are present, give each lock a distinct name following Go conventions -
stateLock
,mapLock
etc.
- Locks should be called