Change-Id: I47e1cc261fdcd6f83a8593893b979d130150d0b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/407174
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
// Output:
// embedded last name: Embedded Doe
}
+
+func ExampleValue_FieldByName() {
+ type user struct {
+ firstName string
+ lastName string
+ }
+ u := user{firstName: "John", lastName: "Doe"}
+ s := reflect.ValueOf(u)
+
+ fmt.Println("Name:", s.FieldByName("firstName"))
+ // Output:
+ // Name: John
+}