Go 编译器抱怨我的代码将切片附加到切片。以下是相关摘录:type LanidEntry struct { lanid string group string contact string}var lanids []LanidEntryfunc load_file() (lanids_loaded []LanidEntry, errormsgs string) { // ...}func Load() (lanids []LanidEntry, errormessages string) { lanids_loaded, errormsgs := load_file(filename1, contact1) lanids = append(lanids, lanids_loaded) // ...}该append行生成此编译器消息: src\load_lanids\load_lanids.go:50: cannot use lanids_loaded (type []LanidEntry) as type LanidEntry in append我知道将切片附加到切片工作正常,基于Go 博客文章中标题为 Append: The built-in function 的部分下的示例。
- 1 回答
- 0 关注
- 181 浏览
添加回答
举报
0/150
提交
取消