Ir al contenido

Too Many Parameters (ARCH5181)

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

Key go.quality.too-many-parameters · Severity warning · Category quality

Long parameter lists make call sites error-prone and unreadable. Group related fields into a struct.

func CreateUser(name, email, phone, city, zip, country string, age int, active bool) error {
// ...
return nil
}
type UserInput struct {
Name, Email, Phone, City, Zip, Country string
Age int
Active bool
}
func CreateUser(in UserInput) error {
// ...
return nil
}

Collect related parameters into a single parameter struct, or inject dependencies instead.