diff options
author | qiulaidongfeng <2645477756@qq.com> | 2023-08-02 00:37:49 +0000 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-08-02 15:25:06 +0000 |
commit | 54e9d6d5efdd03a75574f78e8cf379a9eec79f6d (patch) | |
tree | 51cb22ddbe89fa58ebc91d758c2d49853121f207 /src/reflect | |
parent | 0f1491ded51769588b9306b9d789498dc75b5caa (diff) | |
download | go-54e9d6d5efdd03a75574f78e8cf379a9eec79f6d.tar.gz go-54e9d6d5efdd03a75574f78e8cf379a9eec79f6d.zip |
reflect: update Type.FieldByName documentation
Fixes #61495
Change-Id: I9abaf3613c797006b803dcb1dbee16f25ffb7516
Change-Id: I9abaf3613c797006b803dcb1dbee16f25ffb7516
GitHub-Last-Rev: 7bc2cba77286be1bd322ee31eee3e1df3d8761f1
GitHub-Pull-Request: golang/go#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>
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/type.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go index 6c05aceccf..4254c657d2 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -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 @@ -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. |