go install命令为什么会在bin\windows_386目录下创建一个可执行文件?

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

Why does go install creates an executable in bin\windows_386?

问题

每当我运行go install relative\path\to\package时,它会创建二进制文件,但将它们放在名为windows_386的文件夹中,该文件夹位于$GOPATH\bin文件夹中。我有意将GOARCH设置为386。我在Windows 10专业版上运行go 1.17.1,如果这些信息有关的话。

我的理论是我设置了GOARCH,但以一种“本地”的方式,全局的GOARCH仍然是amd64,每当我安装带有386架构的包时,它们就会被放在这个子文件夹中。然而,我还没有找到任何文献来证实我的怀疑,希望能得到一些见解。

英文:

Whenever I run go install relative\path\to\package it creates the binaries but places them in a folder called windows_386 in the $GOPATH\bin folder. I purposely set GOARCH to the value 386. I'm running go 1.17.1 on Windows 10 Pro edition if this information is relevant.

My theory is that I set GOARCH but in a "local" way, the "global" GOARCH is still amd64 and whenever I install packages with 386 architecture, it puts them in this subfolder. I haven't been able to find any literature to confirm my suspicion though and would like some insight.

答案1

得分: 1

我在2014年提到过go install会遵循GOARCH的设置。

"编译和安装包及其依赖项"部分确实确认了:

当禁用模块感知模式时,其他包会安装在目录$GOPATH/pkg/$GOOS_$GOARCH中。

英文:

I mentioned in 2014 that go install would respect GOARCH

The "Compile and install packages and dependencies" section do confirm that:

> When module-aware mode is disabled, other packages are installed in the directory $GOPATH/pkg/$GOOS_$GOARCH

huangapple
  • 本文由 发表于 2021年10月12日 22:23:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/69542251.html
匿名

发表评论

匿名网友

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

确定