func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error {
	if !n.IsDir() { // key-value pair
		_, name := path.Split(n.Path)

		// find its parent and remove the node from the map
		if n.Parent != nil && n.Parent.Children[name] == n {
			delete(n.Parent.Children, name)
		}

		if callback != nil {
			callback(n.Path)
		}

		if !n.IsPermanent() {
			n.store.ttlKeyHeap.remove(n)
		}

		return nil
	}

	if !dir {
		// cannot delete a directory without dir set to true
		return v2error.NewError(v2error.EcodeNotFile, n.Path, n.store.CurrentIndex)
	}

	if len(n.Children) != 0 && !recursive {
		// cannot delete a directory if it is not empty and the operation
		// is not recursive
		return v2error.NewError(v2error.EcodeDirNotEmpty, n.Path, n.store.CurrentIndex)
	}

	for _, child := range n.Children { // delete all children
		child.Remove(true, true, callback)
	}

	// delete self
	_, name := path.Split(n.Path)
	if n.Parent != nil && n.Parent.Children[name] == n {
		delete(n.Parent.Children, name)

		if callback != nil {
			callback(n.Path)
		}

		if !n.IsPermanent() {
			n.store.ttlKeyHeap.remove(n)
		}
	}

	return nil
}
func (n *node) Remove(dir, recursive bool, callback func(path string)) *v2error.Error {
	if !n.IsDir() { 
		_, name := path.Split(n.Path)

		
		if n.Parent != nil && n.Parent.Children[name] == n {
			delete(n.Parent.Children, name)
		}

		if callback != nil {
			callback(n.Path)
		}

		if !n.IsPermanent() {
			n.store.ttlKeyHeap.remove(n)
		}

		return nil
	}

	if !dir {
		
		return v2error.NewError(v2error.EcodeNotFile, n.Path, n.store.CurrentIndex)
	}

	if len(n.Children) != 0 && !recursive {
		
		
		return v2error.NewError(v2error.EcodeDirNotEmpty, n.Path, n.store.CurrentIndex)
	}

	for _, child := range n.Children { 
		child.Remove(true, true, callback)
	}

	
	_, name := path.Split(n.Path)
	if n.Parent != nil && n.Parent.Children[name] == n {
		delete(n.Parent.Children, name)

		if callback != nil {
			callback(n.Path)
		}

		if !n.IsPermanent() {
			n.store.ttlKeyHeap.remove(n)
		}
	}

	return nil
}
func ( n * node ) Remove ( dir , recursive bool , callback func ( path string ) ) * v2error . Error { if ! n . IsDir ( ) { // key-value pair _ , name := path . Split ( n . Path ) // find its parent and remove the node from the map if n . Parent != nil && n . Parent . Children [ name ] == n { delete ( n . Parent . Children , name ) } if callback != nil { callback ( n . Path ) } if ! n . IsPermanent ( ) { n . store . ttlKeyHeap . remove ( n ) } return nil } if ! dir { // cannot delete a directory without dir set to true return v2error . NewError ( v2error . EcodeNotFile , n . Path , n . store . CurrentIndex ) } if len ( n . Children ) != 0 && ! recursive { // cannot delete a directory if it is not empty and the operation // is not recursive return v2error . NewError ( v2error . EcodeDirNotEmpty , n . Path , n . store . CurrentIndex ) } for _ , child := range n . Children { // delete all children child . Remove ( true , true , callback ) } // delete self _ , name := path . Split ( n . Path ) if n . Parent != nil && n . Parent . Children [ name ] == n { delete ( n . Parent . Children , name ) if callback != nil { callback ( n . Path ) } if ! n . IsPermanent ( ) { n . store . ttlKeyHeap . remove ( n ) } } return nil }
// Remove function remove the node.
Remove function remove the node .