tree

package
v0.0.0-...-29e02a0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendStructFiledSlice

func AppendStructFiledSlice(data interface{}, field string, val interface{}) error

func BuildTree

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

传入的必须是指针数组

func BuildTreeProcess

func BuildTreeProcess(data []interface{}, curLevel []interface{}) error

func BuildTreeWithRoot

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

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

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

func GetStructField

func GetStructField(data interface{}, field string) interface{}

func SetStructField

func SetStructField(data interface{}, field string, val interface{}) error

Types

type BasicTree

type BasicTree struct {
	ID       uint         `json:"id"`
	ParentID uint         `json:"parentId"`
	Title    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