Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

giautm
Copy link
Contributor

@giautm giautm commented Apr 21, 2023

Fixes #8

@giautm giautm force-pushed the g-subtract branch 5 times, most recently from e4c29cc to a5727b7 Compare April 21, 2023 18:42
Signed-off-by: Giau. Tran Minh <[email protected]>
@giautm
Copy link
Contributor Author

giautm commented Apr 22, 2023

cc @jayzhuang, please give some comments or suggestions here. <3

@hayashikun
Copy link

any updates?

@giautm giautm marked this pull request as ready for review October 11, 2023 14:38
@nguyen1212
Copy link

I'm really in need of this PR. Is there any progress ?

@giautm
Copy link
Contributor Author

giautm commented Feb 8, 2024

I also want this. But there are no review from the core team. So...

krhubert added a commit to Archipelago-Team/wire that referenced this pull request Aug 9, 2024
krhubert added a commit to krhubert/wire that referenced this pull request Oct 13, 2024
@nstandif
Copy link

@vangent PTAL

@vangent
Copy link
Contributor

vangent commented Jan 23, 2025

Sorry, I don't maintain this anymore. Try @zombiezen or @eliben .

Copy link

@nstandif nstandif left a 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.

Comment on lines -1176 to +1290
// 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.

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.

Comment on lines -159 to +168
// 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

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.

Comment on lines -178 to +197
// 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).

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{}
}

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 {

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) {

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.

@nstandif
Copy link

@zombiezen PTAL

@zombiezen
Copy link
Collaborator

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wire: add "subtract" command
6 participants