Skip to content

Clarification needed for single-word naming conventions in Go Style Guide #940

@james5635

Description

@james5635

styleguide/go/guide.md

Lines 402 to 412 in 1387bff

### MixedCaps
Go source code uses `MixedCaps` or `mixedCaps` (camel case) rather than
underscores (snake case) when writing multi-word names.
This applies even when it breaks conventions in other languages. For example, a
constant is `MaxLength` (not `MAX_LENGTH`) if exported and `maxLength` (not
`max_length`) if unexported.
Local variables are considered [unexported] for the purpose of choosing the
initial capitalization.

The style guide explains that multi-word names in Go should use MixedCaps (camelCase) rather than underscores. For example:

  • MaxLength (exported)
  • maxLength (unexported)

However, the guide doesn’t clearly state what the convention is for single-word names.

Questions:

  • Should single-word identifiers always be lowercase for unexported names (e.g., count, user)?
  • Should exported single-word identifiers use leading uppercase (e.g., Error, String), similar to how the standard library does it?

This clarification would help newcomers understand whether there are any exceptions or additional rules for single-word names beyond the standard capitalization rules.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:goThe Go language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions