我想迭代这个:
*list.List
我该怎么做?
func Foo(key string, values *list.List) string {
...
//I want to iterate and get value from "values"
}
这个Foo被这样调用:
kvs := make(map[string]*list.List)
res := Foo(k, kvs[k]) //k is string
谢谢!
答案 0 :(得分:5)
查看示例@ http://golang.org/pkg/container/list/:
func Foo(key string, vl *list.List) string {
for e := l.Front(); e != nil; e = e.Next() {
v := e.Value
}
return ""
}
//编辑:检查Create a Golang map of Lists