-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(subtract): added Subtract function to wire #382
base: main
Are you sure you want to change the base?
Conversation
e4c29cc
to
a5727b7
Compare
Signed-off-by: Giau. Tran Minh <[email protected]>
Signed-off-by: Giau. Tran Minh <[email protected]>
cc @jayzhuang, please give some comments or suggestions here. <3 |
any updates? |
I'm really in need of this PR. Is there any progress ? |
I also want this. But there are no review from the core team. So... |
@vangent PTAL |
Sorry, I don't maintain this anymore. Try @zombiezen or @eliben . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not golang core, but these are a few glaring issues I saw. Hope this helps.
// whose element type is the struct type. | ||
// - For a value, this is the type of the expression. | ||
// - For an argument, this is the type of the argument. | ||
// whose element type is the struct type. | ||
// - For a value, this is the type of the expression. | ||
// - For an argument, this is the type of the argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing comments shouldn't be modified, unless you're changing the function definition.
// type S struct { | ||
// MyFoo *Foo | ||
// MyBar *Bar | ||
// } | ||
// var Set = wire.NewSet(wire.Struct(new(S), "MyFoo")) -> inject only S.MyFoo | ||
// var Set = wire.NewSet(wire.Struct(new(S), "*")) -> inject all fields | ||
// type S struct { | ||
// MyFoo *Foo | ||
// MyBar *Bar | ||
// } | ||
// var Set = wire.NewSet(wire.Struct(new(S), "MyFoo")) -> inject only S.MyFoo | ||
// var Set = wire.NewSet(wire.Struct(new(S), "*")) -> inject all fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert comment spacing changes, since you didn't touch this code.
// type S struct { | ||
// MyFoo Foo | ||
// MyBar Bar | ||
// } | ||
// type S struct { | ||
// MyFoo Foo | ||
// MyBar Bar | ||
// } | ||
// | ||
// func NewStruct() S { /* ... */ } | ||
// var Set = wire.NewSet(wire.FieldsOf(new(S), "MyFoo", "MyBar")) | ||
// func NewStruct() S { /* ... */ } | ||
// var Set = wire.NewSet(wire.FieldsOf(new(S), "MyFoo", "MyBar")) | ||
// | ||
// or | ||
// or | ||
// | ||
// func NewStruct() *S { /* ... */ } | ||
// var Set = wire.NewSet(wire.FieldsOf(new(*S), "MyFoo", "MyBar")) | ||
// func NewStruct() *S { /* ... */ } | ||
// var Set = wire.NewSet(wire.FieldsOf(new(*S), "MyFoo", "MyBar")) | ||
// | ||
// If the structType argument is a pointer to a pointer to a struct, then FieldsOf | ||
// additionally provides a pointer to each field type (e.g., *Foo and *Bar in the | ||
// example above). | ||
// If the structType argument is a pointer to a pointer to a struct, then FieldsOf | ||
// additionally provides a pointer to each field type (e.g., *Foo and *Bar in the | ||
// example above). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment spacing should be reverted, since you didn't modify anything here.
@@ -59,6 +59,10 @@ func NewSet(...interface{}) ProviderSet { | |||
return ProviderSet{} | |||
} | |||
|
|||
func Subtract(...interface{}) ProviderSet { | |||
return ProviderSet{} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow the commenting conventions of previous examples. changing spaces to tabs, in this case, is probably OK.
@@ -590,6 +593,115 @@ func (oc *objectCache) processExpr(info *types.Info, pkgPath string, expr ast.Ex | |||
return nil, []error{notePosition(exprPos, errors.New("unknown pattern"))} | |||
} | |||
|
|||
func (oc *objectCache) filterType(set *ProviderSet, t types.Type) []error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
briefly describe what this function does.
return nil | ||
} | ||
|
||
func (oc *objectCache) processSubtract(info *types.Info, pkgPath string, call *ast.CallExpr, args *InjectorArgs, varName string) (interface{}, []error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Briefly describe the function and the args passed.
@zombiezen PTAL |
I do not have the time to shepherd in a new feature in Wire, sorry. (FWIW, the comment spacing changes are fine: gofmt changed within the last couple years and does a better job formatting lists and such.) |
Fixes #8