参考:Managing dependencies - go.dev
GO调用本地代码
module tikv-client-http-go
go 1.16
require (
github.com/tikv/client-go/v2 v2.0.0-unpublished
)
replace github.com/tikv/client-go/v2 v2.0.0-unpublished => ./lib/client-go
GO调用远程包
module tikv-client-http-go
go 1.16
require (
github.com/tikv/client-go/v2 v2.0.0-alpha.0.20210709052506-aadf3cf62721
)
打包在linux上使用:
检查:
LeondeMacBook-Pro:tikv-client-http-go leon$ go env |grep GOARCH GOARCH="amd64" LeondeMacBook-Pro:tikv-client-http-go leon$ go env |grep GOOS GOOS="darwin"
LeondeMacBook-Pro:tikv-client-http-go leon$ go env | grep CGO_ENABLED CGO_ENABLED="1"
执行:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.
chmod 777 main
nohup ./main &
ps -ef|grep main