cmd/cloner: support cloning arbitrarily-nested maps
Fixes #17870 Signed-off-by: Andrew Dunham <andrew@tailscale.com>
This commit is contained in:
committed by
Andrew Dunham
parent
ca9b68aafd
commit
08e74effc0
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type SliceContainer,InterfaceContainer
|
||||
//go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type SliceContainer,InterfaceContainer,MapWithPointers,DeeplyNestedMap
|
||||
|
||||
// Package clonerex is an example package for the cloner tool.
|
||||
package clonerex
|
||||
@@ -32,3 +32,15 @@ func (c *CloneableImpl) Clone() Cloneable {
|
||||
type InterfaceContainer struct {
|
||||
Interface Cloneable
|
||||
}
|
||||
|
||||
type MapWithPointers struct {
|
||||
Nested map[string]*int
|
||||
WithCloneMethod map[string]*SliceContainer
|
||||
CloneInterface map[string]Cloneable
|
||||
}
|
||||
|
||||
// DeeplyNestedMap tests arbitrary depth of map nesting (3+ levels)
|
||||
type DeeplyNestedMap struct {
|
||||
ThreeLevels map[string]map[string]map[string]int
|
||||
FourLevels map[string]map[string]map[string]map[string]*SliceContainer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user