You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
If someone wants to "override" a set of providers from a larger set, it would be helpful to have the gowire tool output the minimal code to create a new provider set that "carves out" the given provider from the set. Ideal workflow:
$ gowire subtract github.com/google/go-cloud/gcp/gcpcloud.GCP github.com/google/go-cloud/gcp.ProjectID
import (
"github.com/google/go-cloud/gcp""github.com/google/go-cloud/gcp/gcpcloud""github.com/google/go-cloud/wire"
)
var Set = wire.NewSet(
gcpcloud.Services,
gcp.CredentialsTokenSource,
gcp.DefaultCredentials,
)
Perhaps this would include an interactive mode that shows you everything in the provider set and lets you pick which types to remove by menu, since typing type names is arduous.
Another idea is to have wire.Subtract be a wire directive, used to wrap a ProviderSet in a wire.NewSet or a wire.Build.
Use cases might be:
I want to make a Set AB that unions 2 other sets A and B, but there's a type T that's the same between A and B.
var SetAB = wire.NewSet(A, B)
Today, you'd get an error that there's two providers for T and you'd be kind of hosed.
With wire.Subtract, you could do:
var SetAB = wire.NewSet(A, wire.Subtract(B, T))
I want to use an existing ProviderSet, but want to override one of the types it provides. For example, azureblob defines a Set that has NewPipeline and Options{} in it. Today, this code would produce an error because Options is provided twice, once by the injector function parameter and once by azureblob.Set.
Reacted by Roxy Light, shantuo, Roger Peppe, Vytis Valentinavičius, Fabien Bernard, Oleksandr Matsak, Alexander Leitan, Alex Shtin, Visitant, hulucc and 7 more
Activity
[-]goose: add "subtract" command[/-][+]wire: add "subtract" command[/+]vangent commentedon Mar 22, 2019
Another idea is to have
wire.Subtractbe a wire directive, used to wrap aProviderSetin awire.NewSetor awire.Build.Use cases might be:
SetAB that unions 2 other sets A and B, but there's a type T that's the same between A and B.wire.Subtract, you could do:ProviderSet, but want to override one of the types it provides. For example, azureblob defines a Set that hasNewPipelineandOptions{}in it. Today, this code would produce an error becauseOptionsis provided twice, once by the injector function parameter and once byazureblob.Set.Again, you'd be kind of hosed; you'd have to explicitly add all of the providers in
azureblob.Setthat you need. Withwire.Subtract, you would do:michaellee8 commentedon Jul 12, 2022
@zombiezen Any chance this will be worked on? Will a PR be accepted if I implement this? This one seems useful for mocking purpose for me.
giautm commentedon Jul 14, 2022
I have same issue here, Just want to change the timeout value in the default server's driver. :(
zombiezen commentedon Jul 17, 2022
This seems reasonable to me, but I haven't been working on Wire for a while. @vangent, WDYT?
vangent commentedon Jul 18, 2022
@eliben can you add the new owners for this repo?
jayzhuang commentedon Jul 31, 2022
wire.Subtractsounds good, I'm happy to help review and merge a PR (new owner here :D)