etcdserver/api/v2store/node.go
func (n *node) Clone() *node {
	if !n.IsDir() {
		newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime)
		newkv.ModifiedIndex = n.ModifiedIndex
		return newkv
	}

	clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime)
	clone.ModifiedIndex = n.ModifiedIndex

	for key, child := range n.Children {
		clone.Children[key] = child.Clone()
	}

	return clone
}
func (n *node) Clone() *node {
	if !n.IsDir() {
		newkv := newKV(n.store, n.Path, n.Value, n.CreatedIndex, n.Parent, n.ExpireTime)
		newkv.ModifiedIndex = n.ModifiedIndex
		return newkv
	}

	clone := newDir(n.store, n.Path, n.CreatedIndex, n.Parent, n.ExpireTime)
	clone.ModifiedIndex = n.ModifiedIndex

	for key, child := range n.Children {
		clone.Children[key] = child.Clone()
	}

	return clone
}
func ( n * node ) Clone ( ) * node { if ! n . IsDir ( ) { newkv := newKV ( n . store , n . Path , n . Value , n . CreatedIndex , n . Parent , n . ExpireTime ) newkv . ModifiedIndex = n . ModifiedIndex return newkv } clone := newDir ( n . store , n . Path , n . CreatedIndex , n . Parent , n . ExpireTime ) clone . ModifiedIndex = n . ModifiedIndex for key , child := range n . Children { clone . Children [ key ] = child . Clone ( ) } return clone }
// Clone function clone the node recursively and return the new node.
// If the node is a directory, it will clone all the content under this directory.
// If the node is a key-value pair, it will clone the pair.
Clone function clone the node recursively and return the new node . If the node is a directory it will clone all the content under this directory . If the node is a key - value pair it will clone the pair .