Go - Naming Conventions & Style

Beginner 10/10 Teacher 10/10 Architect 10/10
Try it: Rename your identifiers to shorter, clearer names where the context is obvious.

Naming

  • Exported identifiers start with uppercase; keep names short but clear.
  • Avoid Hungarian notation; prefer domain terms.

Formatting

  • Always run go fmt ./....
  • Lint with go vet and a linter in CI.

Packages

  • Package names are lower-case, no underscores, short (e.g. http, json).

Common errors

  • Overly long names when scope/context already clarifies meaning.

Practice

  • Refactor a snippet to use short names (r, w, ctx) where appropriate.

Quick quiz

  1. How do you export an identifier?
Show answer Start its name with an uppercase letter (e.g., MyType).