我想在windows环境上开发并安装了go 1.10.1.不过,我需要在linux上部署我的程序。是否有一种方法来构建go程序并指定为linux构建。我已经看到了大量从linux到windows的文档,但不是相反的。
我尝试过的最有希望的例子是:
set GOOS=linux
set GOARCH=amd64
go build filename.go
->它只生成一个exe..。
我正在尝试为我的Go项目创建一个Linux可执行文件。我的配置如下.config-ci.yml在我的gitlab项目中。 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
我一直试图运行./hack/update-all.sh脚本,并且在更新codegen时得到了这个错误:
$ ./hack/update-all.sh
Running in the silent mode, run with -v if you want to see script logs.
Running in short-circuit mode; run with -a to force all scripts to run.
Updating generated-protobuf
Updating codegen
# runtime
/usr/local/go/src/runtime
我在Windows上交叉编译用于Linux的Golang程序,使用:
go build -o myprog.bin myprog.go
为此,我必须设置环境变量GOOS=linux。由于我还在为windows编译一些程序,当我完成交叉编译时,我必须重新设置GOOS=windows。所以我有一个批处理文件,如下所示:
set GOOS=linux
go build -o myprog.bin myprog.go
set GOOS=windows
如果我碰巧同时为每个Linux和Windows编译两个程序,windows程序可能会被编译为Linux。是否有方法将环境变量的范围限制在windows上
我已经在我的Linux机器上用/usr/local/go安装了Go,并且打算使用/usr/local/go/src进行开发。然而,当我尝试这样做时,我得到了以下错误:
$GOPATH must not be set to $GOROOT
实际上,据我所知,这意味着你不应该使用/usr/local/go进行开发。为什么不行?
当我试图最小化一些docker图像时,我开始使用
FROM scratch
但当我这么做的时候我会得到
docker run --rm my/image:latest
standard_init_linux.go:228: exec user process caused: no such file or directory
但是,当我切换回
FROM alpine:latest
执行工作按预期进行。因此,我怀疑我的go应用程序中是否存在换行问题或缺少依赖项。相反,我认为这是因为系统希望/bin/sh可用。但是,与其在黑暗中探查并假设问题...
找出丢失内容的步骤是什么?如何找出文件或目录do
Go已经安装在我的系统中了。路径变量在.bashrc文件中。
# Golang
export PATH=$PATH:/usr/local/go/bin
$ go version
go version go1.16.14 linux/amd64
现在,我愿意使用Beego和bee开发工具。为此,我使用以下命令安装了Beego和Bee。
$ go get -u github.com/beego/beego/v2
$ go get -u github.com/beego/bee/v2
都安装成功了。但是当我使用命令bee version时,它会在终端中产生这种情况。
Command 'bee
使用offciall存档安装go:
摘录:
$ tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz
检查go版本:
$ go version
go version go1.10 linux/amd64
使用作为vim插件,当使用vim打开一个go文件时,它会帮助:
找不到“陷阱”。Run :GoInstallBinaries修复它
因此,当运行:GoInstallBinaries时,收到消息:
没有找到金币。将github.com/lint/golint安装到文件夹..。编译:版本"go1.10.1“与go工具版本"
我想在我的项目中使用spf13/cobra。 spf13/cobra: A Commander for modern Go CLI interactions 键入的install命令结果 $ go get -u github.com/spf13/cobra/cobra
go: downloading github.com/spf13/cobra v1.0.0
go: downloading github.com/spf13/cobra/cobra v0.0.0-20200826151851-02a0d2fbc9e6
go: github.com/spf13/cobra/cobra upgra
我已经在我的Ubuntu桌面上安装了go,在我关闭电脑之前,它工作得很好。
现在,当我启动我的机器并继续我的项目工作时,我得到了这样的结果
$ go build
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"
go tool: no such tool "compile"
当我尝试构建一个项目时。
我在断电前做
我用go build -o myApp在我的Ubuntu20.04操作系统中构建了我的Go应用程序。
当我在18.04上运行此应用程序时,会发生以下错误:
/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./myApp)
当我在堆栈溢出中搜索时,有人提到在服务器上安装glibc 2.29。但其他人回答说,这种方式是危险的,可能会破坏操作系统。
还有人建议用glibc 2.27开发应用程序。
我该怎么做?
为我的Go应用程序构建一个容器会遇到环境变量方面的问题。
在我的本地机器上,我可以执行以下操作:
export GIN_MODE=release
go build -a
这将以一种方式编译我的应用程序,其中名为GIN的库将注意到GIN_MODE env变量并表现出不同的行为。
当我运行应用程序时,它将声明
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
-