Back to all reviewers

Descriptive idiomatic identifiers

gin-gonic/gin
Based on 4 comments
Go

Use descriptive names for variables, types, and interfaces that follow Go language idioms. Avoid single-letter variables or cryptic abbreviations that reduce code readability.

Naming Conventions Go

Reviewer Prompt

Use descriptive names for variables, types, and interfaces that follow Go language idioms. Avoid single-letter variables or cryptic abbreviations that reduce code readability.

Key guidelines:

  1. Follow Go interface naming conventions by using the “-er” suffix for interfaces that describe behavior (e.g., Validator instead of ValidatorImp).

  2. Don’t repeat the package name in type names. When a type is in a package that describes its domain: ```go // AVOID package json type JsonApi interface { … }

// PREFER package json type API interface { … }


3. Choose descriptive variable names, especially avoiding single letters that can be confused with numbers:
```go
// AVOID
for l := len(skippedNodes); l > 0; l-- {
    // ...
}

// PREFER
for length := len(skippedNodes); length > 0; length-- {
    // ...
}
  1. Avoid cryptic abbreviations like ldi or ri in favor of complete words like levelOneRouterIndex or recordIndex.

Clear, descriptive, and idiomatic naming improves code readability and maintenance, making it easier for team members to understand the code’s purpose and behavior without additional context.

4
Comments Analyzed
Go
Primary Language
Naming Conventions
Category

Source Discussions