cmd/{cloner,viewer}: handle maps of views
Instead of trying to call View() on something that's already a View type (or trying to Clone the view unnecessarily), we can re-use the existing View values in a map[T]ViewType. Fixes #17866 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
This commit is contained in:
committed by
Andrew Dunham
parent
f4f9dd7f8c
commit
6ac80b7334
@@ -547,3 +547,20 @@ func _GenericTypeAliasStructCloneNeedsRegeneration[T integer, T2 views.ViewClone
|
||||
Cloneable T2
|
||||
}{})
|
||||
}
|
||||
|
||||
// Clone makes a deep copy of StructWithMapOfViews.
|
||||
// The result aliases no memory with the original.
|
||||
func (src *StructWithMapOfViews) Clone() *StructWithMapOfViews {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := new(StructWithMapOfViews)
|
||||
*dst = *src
|
||||
dst.MapOfViews = maps.Clone(src.MapOfViews)
|
||||
return dst
|
||||
}
|
||||
|
||||
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
||||
var _StructWithMapOfViewsCloneNeedsRegeneration = StructWithMapOfViews(struct {
|
||||
MapOfViews map[string]StructWithoutPtrsView
|
||||
}{})
|
||||
|
||||
Reference in New Issue
Block a user