There are a lot of consistent behaviors that Go programmers like to retain in order to keep readable, maintainable code. Go naming schemes tend to be consistent, accurate, and short. We want to create names with the following idioms in mind:
- Local variables for iterators should be short and simple:
- i for an iterator; i and j if you have a two-dimensional iterator
- r for a reader
- w for a writer
- ch for channels
- Global variable names should be short and descriptive:
- RateLimit
- Log
- Pool
- Acronyms should follow the convention of using all capitals:
- FooJSON
- FooHTTP
- Avoid stuttering with the package name:
- log.Error() instead of log.LogError()
- Interfaces with one method should follow the method name plus the -er suffix:
- Stringer
- Reader
- Writer
- Logger
- Names in Go should follow a Pascal or mixedCaps case method:
- var ThingOne
- var thingTwo