directory

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindCommonRootDirectory

func FindCommonRootDirectory(filePaths []string) string

FindCommonRootDirectory 查找所有路径的共同根目录

func Walk

func Walk(node *TreeNode, cb WalkFunc)

Types

type TreeNode

type TreeNode struct {
	Name     string               // 节点名称
	Children map[string]*TreeNode // 子节点
	Value    interface{}          // 存储任意类型的值
}

TreeNode 表示目录树的节点

func BuildDirectoryTree

func BuildDirectoryTree(filePaths []string) *TreeNode

BuildDirectoryTree 构建目录树

func (*TreeNode) AddPath

func (node *TreeNode) AddPath(path string)

AddPath 将目录路径添加到目录树中

func (*TreeNode) AddValue

func (node *TreeNode) AddValue(childPath string, value interface{}) error

AddValue 添加值到目标节点

func (*TreeNode) GetNode

func (node *TreeNode) GetNode(path string) *TreeNode

func (*TreeNode) GetValue

func (node *TreeNode) GetValue(path string) (interface{}, error)

GetValue 通过路径获取值

type WalkFunc

type WalkFunc func(dir string, value any)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL