您现在的位置是:首页 >技术教程 >termux下go交叉编译和依赖包引用网站首页技术教程

termux下go交叉编译和依赖包引用

horizon_zpy 2024-05-31 12:00:03
简介termux下go交叉编译和依赖包引用

交叉编译windows的exe

export GOPROXY=https://proxy.golang.com.cn,direct
go mod tidy

必须写在一行
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build hello3.go

If you are experiencing issues with downloading packages from the official Go module proxy, you can try using an alternative proxy like goproxy.cn. This is a popular Go module proxy server in China, which provides a mirror of the official Go module proxy server and can help to speed up the download process for Chinese developers.

To use goproxy.cn, you can set the GOPROXY environment variable to https://goproxy.cn:

export GOPROXY=https://goproxy.cn

This will instruct the Go tool to use goproxy.cn as the primary module proxy server for downloading packages.

You can also set this environment variable permanently in your shell profile file (e.g. .bashrc, .zshrc, etc.) if you want it to be set every time you start a new terminal session.

After setting the GOPROXY environment variable, you can try running the go get command again to download the required package. The Go tool will now use goproxy.cn as the module proxy server, which may help to resolve any network issues that you were experiencing with the official proxy server.

I have downloaded the package and placing it in the correct directory in …/go/pkg/mod/github.com/xuri/excelize@v1.4.1/

How should I modify go.mod to make it work?

go.mod修改运行已经下载的包
https://golang.google.cn/doc/tutorial/call-module-code
$ go mod edit -replace example.com/greetings=…/greetings
module

replace github.com/xuri/excelize => /path/to/excelize

require (
github.com/xuri/excelize v1.4.1
)

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。