我正在尝试为我的Go项目制作一个Linux可执行文件。在我的gitlab项目中,我有以下配置。.config-ci.yml
demo_job_1:
tags:
- cpf
- cpf-test
- testing
- unit-testing
script:
- go run test/main.go
- GOOS=linux GOARCH=amd64 go build
- go env
- cd test
- ./test
- echo Successfully run and Built
运行此管道后,当我签入env文件时,我仍然会得到GOOS =windows。我如何构建我的项目,以便构建后的输出是Linux可执行文件。现在,我得到了.exe仅在Windows上运行的文件。
您可以在以下 gitlab 中查看项目详细信息:
https://gitlab.com/smilekison/test
这是管道作业显示的错误:
$ go run test/main.go
Hello world
$ GOOS=linux GOARCH=amd64 go build
GOOS=linux : The term 'GOOS=linux' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script487326907\script.ps1:207 char:1
+ GOOS=linux GOARCH=amd64 go build
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (GOOS=linux:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException