aboutsummaryrefslogtreecommitdiff
path: root/src/reflect/type.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2024-03-02 19:27:21 -0800
committerGopher Robot <gobot@golang.org>2024-04-19 17:15:47 +0000
commit2ff89341f643920f827e4c45db8e4b507fedd9f0 (patch)
tree0655297d859b58df9e87a91902d476995b7ca862 /src/reflect/type.go
parentf0d6ddfac03c1c3048f20d595fd50352c79e1849 (diff)
downloadgo-2ff89341f643920f827e4c45db8e4b507fedd9f0.tar.gz
go-2ff89341f643920f827e4c45db8e4b507fedd9f0.zip
reflect: omit anonymous field name from StructOf type string
This makes the reflect package match the compiler for StructOf with an embedded field. Fixes #24781 Change-Id: Ice64b167cbe0b9d30a953c5d8e2a86f3ad1158bf Reviewed-on: https://go-review.googlesource.com/c/go/+/567897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/reflect/type.go')
-rw-r--r--src/reflect/type.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go
index 272f0b87d1..cfefb4c27c 100644
--- a/src/reflect/type.go
+++ b/src/reflect/type.go
@@ -2287,8 +2287,9 @@ func StructOf(fields []StructField) Type {
// Update string and hash
name := f.Name.Name()
hash = fnv1(hash, []byte(name)...)
- repr = append(repr, (" " + name)...)
- if f.Embedded() {
+ if !f.Embedded() {
+ repr = append(repr, (" " + name)...)
+ } else {
// Embedded field
if f.Typ.Kind() == abi.Pointer {
// Embedded ** and *interface{} are illegal