mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 05:07:33 +00:00
util/codegen: support embedded fields
I noticed cmd/{cloner,viewer} didn't support structs with embedded fields while working on a change in another repo. This adds support. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
ea84fc9ad2
commit
4f454f4122
@@ -202,13 +202,18 @@ func AssertStructUnchanged(t *types.Struct, tname, ctx string, it *ImportTracker
|
||||
w("var _%s%sNeedsRegeneration = %s(struct {", tname, ctx, tname)
|
||||
|
||||
for i := 0; i < t.NumFields(); i++ {
|
||||
fname := t.Field(i).Name()
|
||||
st := t.Field(i)
|
||||
fname := st.Name()
|
||||
ft := t.Field(i).Type()
|
||||
if IsInvalid(ft) {
|
||||
continue
|
||||
}
|
||||
qname := it.QualifiedName(ft)
|
||||
w("\t%s %s", fname, qname)
|
||||
if st.Anonymous() {
|
||||
w("\t%s ", fname)
|
||||
} else {
|
||||
w("\t%s %s", fname, qname)
|
||||
}
|
||||
}
|
||||
|
||||
w("}{})\n")
|
||||
|
Reference in New Issue
Block a user