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

ElementConventionExample
Packagelowercase, single wordhttp, fmt, json
VariablecamelCaseuserName, maxRetries
Function (exported)PascalCaseParseJSON
Function (unexported)camelCaseparseJSON
InterfacePascalCase + -er suffixReader, Writer, Stringer
StructPascalCaseHttpClient
ConstantcamelCase or PascalCasemaxSize, 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() not user.GetName()
  • Package names should not repeat in exported names: http.Client not http.HttpClient

Convert

camelCase or PascalCase converter. Hub.