Go Style
Jump to navigation
Jump to search
External
- https://google.github.io/styleguide/go/
- https://go.dev/doc/effective_go
- https://github.com/golang/go/wiki/CodeReviewComments
Internal
Overview
The Go standard library is a good source of code examples, comments and style.
Naming
Naming is one of the most important aspects of Go development. Writing idiomatic Go requires understanding of its core naming principles.
Identifiers should use camel case: SomeColor
or someColor
, depending on whether they are visible outside the package or not. Do not use snake case some_color
.
Acronyms should have a consistent case. URL
or url
is correct, Url
is not.
When a variable, struct or interface is imported from another package, its name includes the package name or alias: mypackage.MyVar
.
Other naming conventions: