tree

package
v0.0.0-...-3a73874 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTree

func BuildTree(input []interface{}) ([]interface{}, error)

func BuildTreeWithRoot

func BuildTreeWithRoot(data []interface{}, rootNode interface{}, mode int) ([]interface{}, error)

data 必须为指针数组 rootNode 必须为指针 mode:

1 : 自动增加根节点, 并且是一棵树. 即跟节点之外的节点都是跟节点的孩子
2 : 自动增加根节点, 但是多棵树, 跟节点下没有孩子,默认跟第一级同级

Types

type BasicTree

type BasicTree struct {
	ID       uint         `json:"id"`
	ParentID uint         `json:"parentId"`
	Name     string       `json:"name"`
	Children []*BasicTree `json:"children"`
}

Jump to

Keyboard shortcuts

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