Maintain consistent naming conventions throughout the codebase by following established patterns and avoiding redundancy. Key principles include:
Error naming: Use the pattern Err + [Subject] + [Error Condition]
(e.g., ErrStorageRetrievalFailed
instead of ErrNotGetStorage
)
Test/benchmark naming: Include underscores for consistency (Test_
and Benchmark_
prefixes)
Constant naming: Use descriptive names that indicate purpose (DefaultFormat
instead of FormatDefault
)
Avoid redundant prefixes: Don’t repeat package context in type names (KeyLookupFunc
instead of KeyauthKeyLookupFunc
)
Use proper English: Avoid non-standard plurals or constructions (AllFormData()
instead of FormDatas()
)
Function naming: Choose concise, clear names that match existing patterns (FromContext()
instead of FromGoContext()
, Logger()
to match similar functions)
Example of consistent error naming:
// Good - follows Err + Subject + Condition pattern
ErrStorageRetrievalFailed = errors.New("unable to retrieve data from CSRF storage")
ErrStorageSaveFailed = errors.New("unable to save data to CSRF storage")
// Avoid - inconsistent pattern
ErrNotGetStorage = errors.New("unable to retrieve data from CSRF storage")
This ensures code readability and helps developers quickly understand naming conventions when contributing to the project.
Enter the URL of a public GitHub repository