Waiting for input...
Star SPIKE on GitHub

ADR-0015: Use Singular Form for File and Package Naming


  • Status: accepted
  • Date: 2024-11-18
  • Tags: Convention, Naming, Go

Context

Our codebase needs consistent naming conventions for Go files and packages. While Go has a strict convention for package names (singular), file naming is less standardized. This inconsistency can lead to maintenance overhead and cognitive load when working with the codebase.

Decision

We will use singular form for both file names and package names unless plural form provides clear additional clarity or disambiguation.

Examples:

  • entity.go over entities.go
  • user.go over users.go
  • config.go over configs.go

Exceptions allowed when:

  • Plural form better represents the file’s contents (e.g., constants.go for a file containing only constants)
  • Disambiguation is needed (e.g., users_api.go vs user_model.go)

Consequences

Positive

  • Consistent with Go’s package naming convention
  • Reduces decision overhead
  • Easier maintenance and navigation
  • Aligns with Go standard library practices

Negative

  • May require renaming existing files
  • Some edge cases may require team discussion