Skip to content

Commit

Permalink
reflect: update Type.FieldByName documentation
Browse files Browse the repository at this point in the history
Fixes #61495

Change-Id: I9abaf3613c797006b803dcb1dbee16f25ffb7516

Change-Id: I9abaf3613c797006b803dcb1dbee16f25ffb7516
GitHub-Last-Rev: 7bc2cba
GitHub-Pull-Request: #61645
Reviewed-on: https://go-review.googlesource.com/c/go/+/514035
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
  • Loading branch information
qiulaidongfeng authored and gopherbot committed Aug 2, 2023
1 parent 0f1491d commit 54e9d6d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/reflect/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ type Type interface {

// FieldByName returns the struct field with the given name
// and a boolean indicating if the field was found.
// If the returned field is promoted from an embedded struct,
// then Offset in the returned StructField is the offset in
// the embedded struct.
FieldByName(name string) (StructField, bool)

// FieldByNameFunc returns the struct field with a name
Expand All @@ -186,6 +189,10 @@ type Type interface {
// and FieldByNameFunc returns no match.
// This behavior mirrors Go's handling of name lookup in
// structs containing embedded fields.
//
// If the returned field is promoted from an embedded struct,
// then Offset in the returned StructField is the offset in
// the embedded struct.
FieldByNameFunc(match func(string) bool) (StructField, bool)

// In returns the type of a function type's i'th input parameter.
Expand Down

0 comments on commit 54e9d6d

Please sign in to comment.