Get a tree like structure out of path string
问题 I am stuck since 2 days, as I am not to firm with pointers and recursion. I have an array of path like structures, lets say: s:=[]string { "a/b/c", "a/b/g", "a/d", } With a data structure like this: type Node struct { Name string `json:"name"` Children []Node `json:"children"` } I would like to end up with something like this: { "name": "a", "children": [ { "name": "b", "children": [ { "name": "c", "children": [] }, { "name": "g", "children": [] } ] }, { "name": "d", "children": [] } ] } I