Skip to content

Commit

Permalink
relax VisitDependencies to allow interface{} values as is
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Mar 3, 2023
1 parent 199ed85 commit 54d7e00
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 834 deletions.
9 changes: 7 additions & 2 deletions dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ type DependencyVisitor func(Dependency) bool
//
// For non-struct values or for structs that do not embed fx.In, the visitor is simply invoked
// with that value but with Name, Group, etc fields left unset.
func VisitDependencies(visitor DependencyVisitor, deps ...reflect.Value) {
for _, dv := range deps {
func VisitDependencies(visitor DependencyVisitor, deps ...any) {
for _, dep := range deps {
dv, ok := dep.(reflect.Value)
if !ok {
dv = reflect.ValueOf(dep)
}

// for any structs that embed fx.In, recursively visit their fields
if dig.IsIn(dv.Type()) {
for stack := []reflect.Value{dv}; len(stack) > 0; {
Expand Down
22 changes: 21 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/xmidt-org/arrange

go 1.15
go 1.19

require (
github.com/gorilla/mux v1.8.0
Expand All @@ -13,3 +13,23 @@ require (
go.uber.org/fx v1.19.2
go.uber.org/multierr v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 54d7e00

Please sign in to comment.