
./slice.go:5:1: syntax error: non-declaration statement outside function body
意思就是在func外,每个语句都必须是golang的关键字开始,否则就报这个错,写在函数体内就好。

这应该也是一种可以的解决方案
syntax error: non-declaration statement outside function body_小马过河-优快云博客
博客解释了在Go语言中遇到的'syntaxerror:non-declaration statement outside function body'错误,指出该错误意味着在函数外部的语句必须以关键字开头。解决方案是将语句放入函数体内。内容主要针对Go编程初学者。

./slice.go:5:1: syntax error: non-declaration statement outside function body
意思就是在func外,每个语句都必须是golang的关键字开始,否则就报这个错,写在函数体内就好。

这应该也是一种可以的解决方案
syntax error: non-declaration statement outside function body_小马过河-优快云博客

被折叠的 条评论
为什么被折叠?