Go (Golang) Naming Conventions: The Complete Reference
5 min read
Go enforces naming conventions through its visibility rules: capitalized names are exported (public), lowercase are unexported (private).
Visibility by Case
func GetUser() {} // Exported — accessible from other packages
func getUser() {} // Unexported — package-private
Conventions
| Element | Convention | Example |
|---|---|---|
| Package | lowercase, single word | http, fmt, json |
| Variable | camelCase | userName, maxRetries |
| Function (exported) | PascalCase | ParseJSON |
| Function (unexported) | camelCase | parseJSON |
| Interface | PascalCase + -er suffix | Reader, Writer, Stringer |
| Struct | PascalCase | HttpClient |
| Constant | camelCase or PascalCase | maxSize, StatusOK |
Go-Specific Rules
- No SCREAMING_SNAKE_CASE for constants — Go uses camelCase/PascalCase
- Acronyms stay all-caps:
HTTPClient,XMLParser,URL - Getters don't use "Get" prefix:
user.Name()notuser.GetName() - Package names should not repeat in exported names:
http.Clientnothttp.HttpClient
Convert
camelCase or PascalCase converter. Hub.