当我试图在linux中构建时,Go应用程序无法构建。同样的应用程序在Windows中构建良好
我用来建置项目的命令:转到构建meddeals_server
它在我的Windows机器上正常工作,当我将其停靠或部署在云Linux示例上时出现问题。
文件夹结构
C:\proj\MEDDEALS_SERVER
│ .gitignore
│ Dockerfile
│ go.mod
│ go.sum
│ main.go
│ meddeals_server.exe
│
├───.netlify
│ state.json
│
├───controller
│ Apollo.go
│ Buddy.go
│ Net.go
│ MG.go
│ Forever.go
│
├───entity
│ Apollo.go
│ GeoIP.go
│ MedCard.go
│ Buddy.go
│ Search.go
│ Net.go
│ One.go
│ Forever.go
│
└───utility
HttpHelper.go
云出错
- 错误:软件包meddeals_server/控制器不在GOROOT中(/opt/buildhome/. gimme/versions/go1.19.3.linux.amd64/src/meddeals_server/控制器)**
Docker出错
- #9 7.718主星。出发:4:2:/usr/local/go/src/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server/server执行程式无法执行[/bin/sh-c go build-o main.]:退出代码:1*
奇怪的是,同样的构建命令在我的Windows机器上工作得很好,但在其他环境中却不行。
1条答案
按热度按时间igetnqfo1#
经过多次重试,我已经解决了这个问题。问题是GO版本在Docker和其他云示例上是不同的,这就是为什么我会遇到这个问题。因为这个错误是误导性的,所以花了很多时间来解决它。
我在Docker和Cloud示例上匹配了Go版本,然后构建工作正常。
谢谢大家!