wire: wire.FieldsOf should not provide pointer to field type for non-pointer structs (#210)

This commit is contained in:
Robert van Gent
2019-09-05 14:17:17 -07:00
committed by GitHub
parent f85ec5c4a6
commit c385f07c5d
16 changed files with 100 additions and 23 deletions

10
wire.go
View File

@@ -173,11 +173,11 @@ type StructFields struct{}
// to provide the types of those fields. The structType argument must be a
// pointer to the struct or a pointer to a pointer to the struct it wishes to reference.
//
// The following example would provide *Foo and *Bar using S.MyFoo and S.MyBar respectively:
// The following example would provide Foo and Bar using S.MyFoo and S.MyBar respectively:
//
// type S struct {
// MyFoo *Foo
// MyBar *Bar
// MyFoo Foo
// MyBar Bar
// }
//
// func NewStruct() S { /* ... */ }
@@ -187,6 +187,10 @@ type StructFields struct{}
//
// 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).
func FieldsOf(structType interface{}, fieldNames ...string) StructFields {
return StructFields{}
}