Ir al contenido

Boolean Prefix (ARCH5007)

Esta página aún no está disponible en tu idioma.

Key go.naming.boolean-prefix · Severity info · Category naming

Boolean-typed members and accessors should carry an interrogative prefix such as is/has/can/should, otherwise conditionals read poorly. The accurate form needs a type-aware mode.

type Account struct {
Active bool
Premium bool
}
type Account struct {
IsActive bool
HasPremium bool
}

Add an interrogative prefix like is/has/can/should to boolean fields.