这是代码,我使用 gccgo 进行编译。这是基于图形的组织者。我不需要关于图算法的建议。package elementimport ( "fmt" "strings" "io" "strconv")type Node struct { id int name string props map[string]string links map[string][]*Node}var names = make(map[string]int , 8)var nodes = make(map[string][]*Node , 8)//========functions================func new_node(Id int) *Node { return &Node( Id, " ", nil, nil) }func getNode_byId(nodes []*Node, id int) *Node { for _, node := range nodes{ if node.id == id { return node } } return nil}func addNode(store string, node *Node) { nodes[store] = append(nodes[store], node)}func addLinkToNode(node, link *Node, property string) { node.links[property] = append(node.links[property], link)}func nodeFromString(str string, typ string) { lines := strings.Split(str, "\n") lcount := len(lines) if lines[0] == "[begin]" && lines[lcount] == "[end]" { fmt.Println("common dude! something wrong with ur string") return } fields := strings.Fields(lines[1]) id , _ := strconv.Atoi(fields[1]) nod := getNode_byId(nodes[typ], id ) if nod == nil { nod = new_node(id) } addNode(typ, nod) nod.name = typ lines = lines[2:] ind :=0 for index, line := range lines { fields := strings.Fields(line) if field := fields[0]; field[0] != '-' { ind = index break } nod.props[fields[0]] = fields[1] } lines = lines[ind:] for index, line := range lines { if line[0]!= '+' { ind = index break } pivot := strings.Index(line, " ") field := line[0:pivot] fields := strings.Split(line[pivot:], ",") 这是我得到的错误,我尽力了,但我无法解决。$ gccgo elements.goelements.go:23:19: error: expected ‘)’elements.go:23:34: error: expected ‘;’ or ‘}’ or newlineelements.go:23:2: error: too many values in return statementelements.go:91:4: error: value computed is not used我不明白在哪里需要使用分号以及为什么。
1 回答
- 1 回答
- 0 关注
- 262 浏览
添加回答
举报
0/150
提交
取消