Skip to content

component: WithQualifierFor applies qualifier to multiple matching constructor arguments #47

Description

@burakkoken

Procyon version

current main branch

Go version

go1.24

What did you do?

Used WithQualifierFor[T] on a constructor that has multiple parameters with the same type.

func NewService(primary *Client, replica *Client) *Service {
	return &Service{
		primary: primary,
		replica: replica,
	}
}

component.Register(
	NewService,
	component.WithQualifierFor[*Client]("primaryClient"),
)

What did you see happen?

The qualifier is applied to every constructor argument matching the given type.

In this case, both primary and replica receive the primaryClient qualifier.

What did you expect to see?

WithQualifierFor[T] should not silently apply the same qualifier to multiple constructor arguments of the same type.

If more than one constructor argument matches type T, registration should fail with a clear error, because the qualifier target is ambiguous.

Additional context

A separate option such as WithQualifierAt(index, name) can be used for constructors that need different qualifiers for multiple arguments of the same type.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions