cmd/{cloner,viewer}: add support for map values with pointers

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2022-07-12 23:52:44 -07:00
committed by Maisem Ali
parent 26f103473c
commit 95d43c54bf
5 changed files with 34 additions and 8 deletions

View File

@@ -127,6 +127,13 @@ func (src *Map) Clone() *Map {
dst.StructWithPtrKey[k] = v
}
}
if dst.StructWithPtr != nil {
dst.StructWithPtr = map[string]StructWithPtrs{}
for k, v := range src.StructWithPtr {
v2 := v.Clone()
dst.StructWithPtr[k] = *v2
}
}
return dst
}
@@ -143,6 +150,7 @@ var _MapCloneNeedsRegeneration = Map(struct {
SliceIntPtr map[string][]*int
PointerKey map[*string]int
StructWithPtrKey map[StructWithPtrs]int
StructWithPtr map[string]StructWithPtrs
}{})
// Clone makes a deep copy of StructWithSlices.