]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: update Type.FieldByName documentation
authorqiulaidongfeng <2645477756@qq.com>
Wed, 2 Aug 2023 00:37:49 +0000 (00:37 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 2 Aug 2023 15:25:06 +0000 (15:25 +0000)
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>

src/reflect/type.go

index 6c05aceccf1516325d26ed14db7a5d5e6239a7d4..4254c657d2d8bd32002cb8bc465f8620d472375f 100644 (file)
@@ -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.