-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
lang:goThe Go languageThe Go language
Description
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
Labels
lang:goThe Go languageThe Go language