Procyon|Docs
ComponentsRegistration

Naming

Use generated names or assign explicit names when needed.

Procyon generates a component name from the constructor return type. For example, NewUserService() *UserService becomes userService.

register.go
func init() {
	component.Register(NewUserService)
}

Generated names are enough when a type has one clear implementation.

Explicit names

Use component.WithName when the generated name is not the name you want, or when multiple components share an interface.

mail.go
func init() {
	component.Register(
		NewPrimaryMailer,
		component.WithName("primaryMailer"),
	)
}

func NewPrimaryMailer() Mailer {
	return &SmtpMailer{}
}

Explicit names are also used by qualifiers when constructor injection needs a specific implementation.

service.go
component.Register(
	NewNotificationService,
	component.WithQualifierFor[Mailer]("primaryMailer"),
)

Naming guidance

  • Prefer generated names for simple concrete services.
  • Use explicit names for multiple implementations.
  • Keep names stable because other definitions may qualify against them.
  • Avoid names that describe environment state; use conditions for that.