“GO111MODULE” 不被识别为内部或外部命令。

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

'GO111MODULE' is not recognized as an internal or external command

问题

我在Windows机器上克隆了go repo,并尝试构建它(已安装make,版本为v4.3):

> make tempo

它给出了错误信息:

FIND: 参数格式不正确
FIND: 参数格式不正确
文件未找到 - "*.yaml"
在....\tempo中没有Go文件
process_begin: CreateProcess(NULL, uname -s, ...) 失败。
Makefile:51: pipe: Bad file descriptor
'.' 不是内部或外部命令,也不是可运行的程序或批处理文件。
GO111MODULE=on CGO_ENABLED=0 go build -mod vendor -ldflags "-X main.Branch=fix2308 -X main.Revision=e92189167 -X main.Version=" -o ./bin/windows/tempo-amd64  ./cmd/tempo
'GO111MODULE' 不是内部或外部命令,也不是可运行的程序或批处理文件。
make: *** [Makefile:63: tempo] Error 1

我已将环境变量GO111MODULE设置为on。

我应该如何解释这个错误信息?

英文:

I have cloned go repo on windows machine,and am trying to build it(make is installed, v4.3):

> make tempo

It gives me error:

FIND: Parameter format not correct
FIND: Parameter format not correct
File not found - "*.yaml"
no Go files in ....\tempo
process_begin: CreateProcess(NULL, uname -s, ...) failed.
Makefile:51: pipe: Bad file descriptor
'.' is not recognized as an internal or external command,
operable program or batch file.
GO111MODULE=on CGO_ENABLED=0 go build -mod vendor -ldflags "-X main.Branch=fix2308 -X main.Revision=e92189167 -X main.Version=" -o ./bin/windows/tempo-amd64  ./cmd/tempo
'GO111MODULE' is not recognized as an internal or external command,
operable program or batch file.
make: *** [Makefile:63: tempo] Error 1

I have set env var GO111MODULE to on.

How should I interpret this message?

答案1

得分: 3

设置环境变量并运行像GO111MODULE=on CGO_ENABLED=0 go build这样的命令在Windows上不受支持。一个解决方法是在由"Git for Windows"提供的"Git Bash"中运行make tempo。我刚刚测试了一下,它可以工作:

zeke@my-PC MINGW64 /d/src/temp/tempo (main)
$ make tempo
GO111MODULE=on CGO_ENABLED=0 go build -mod vendor -ldflags "-X main.Branch=main -X main.Revision=e92189167 -X main.Version=main-e921891" -o ./bin/windows/tempo-amd64  ./cmd/tempo

注意:输出文件./bin/windows/tempo-amd64没有扩展名.exe。记得重命名这个文件并添加扩展名。

英文:

The way to set environment variables and run a command like GO111MODULE=on CGO_ENABLED=0 go build is not supported by Windows. A workaround is to run make tempo in "Git Bash" shipped by "Git for Windows". I just had a test and it worked:

zeke@my-PC MINGW64 /d/src/temp/tempo (main)
$ make tempo
GO111MODULE=on CGO_ENABLED=0 go build -mod vendor -ldflags "-X main.Branch=main -X main.Revision=e92189167 -X main.Version=main-e921891" -o ./bin/windows/tempo-amd64  ./cmd/tempo

Note: the output file ./bin/windows/tempo-amd64 does not have the extension .exe. Remember to rename this file to add the extension.

huangapple
  • 本文由 发表于 2023年4月25日 12:57:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76097738.html
匿名

发表评论

匿名网友

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

确定