英文:
When Go source file named arm.go, no identifiers are recognized
问题
我相信这是当前Golang实现中的一个错误,但我不完全确定。
假设我有两个Go源文件:
test1.go:
package tmp
func test1() {
test2()
}
other.go:
package tmp
func test2() {}
它们可以无错误地构建;test2()位于test1()所在的tmp包中。
然而,如果我将other.go重命名为arm.go,编译器会报错:
undefined: test2
... 这相当奇怪;除了arm.go之外,任何其他名称似乎都可以正常工作。有什么想法吗?
英文:
I believe this is a bug in the current Golang implementation, but I'm not completely sure.
Say I have two Go source files:
test1.go:
package tmp
func test1() {
test2()
}
other.go:
package tmp
func test2() {}
They build with no errors; test2() is located in package tmp by test1()
However, if I rename other.go to arm.go, the compiler gives:
undefined: test2
... it's rather strange; any other name seems to work fine, except arm.go. Ideas?
答案1
得分: 3
arm.go文件名很特殊(参见http://golang.org/pkg/go/build/#hdr-Build_Constraints)。该文件只会在GOARCH=arm时进行构建。我怀疑你的CPU不同,所以该文件被排除在外。
Alex
英文:
arm.go file name is special (see http://golang.org/pkg/go/build/#hdr-Build_Constraints). The file will only be built on GOARCH=arm. I suspect you have different CPU, so the file is excluded.
Alex
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论