Naming Convention in Go
Variables
- Use
camelCase - Acronyms should be all capitals, as in
ServeHTTP - Single letter represents index:
i,j,k - Short but descriptive names:
custnotcustomer - Repeat letters to represent collection, slice, or array and use single letter in loop:
var tt []*Thing
for i, t := range tt {
// ...
}
- Avoid repeating package name:
log.Info() // good
log.LogInfo() // bad
- Don’t name like getters or setters:
custSvc.cust() // good
custSvc.getCust() // bad
- Add `er to Interface:
type Stringer interfaces {
String() string
}