go文档模式,编译出错,各位道友帮忙看看

meijies · · 1203 次点击
<a href="/user/polaris" title="@polaris">@polaris</a> 谢谢,问题解决了
#7
更多评论
```go package config import &#34;strings&#34; type doc struct { value string sub map[string]doc } var root = new(doc) func Add(key string, value string) { keys := strings.Split(key, &#34;.&#34;) var target = root for index, subkey := range keys { if target.sub == nil { target.sub = make(map[string]doc) target.sub[subkey] = doc{} } if index == len(keys)-1 { target.sub[subkey].value = value } else { target = target.sub[subkey] } } } func Get(key string) string { keys := strings.Split(key, &#34;.&#34;) target := root for index, subkey := range keys { target = target.sub[subkey] if index == len(keys)-1 { return target.value } } return &#34;&#34; } ```
#1
![Screenshot from 2017-10-30 20-19-50.png](https://static.studygolang.com/171030/b599ad4bb42aab899d3ffb1984da7381.png)
#2