当Go源文件命名为arm.go时,无法识别任何标识符。

huangapple go评论92阅读模式
英文:

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

huangapple
  • 本文由 发表于 2013年12月30日 12:20:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/20833298.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定