简体   繁体   中英

Getting a dependency error on my go build

I am getting a dependency error on my go build and I don't understand it yet. Building and compiling locally works just fine. The issue is when I try to run and build in my docker container then I get this error.

go: github.com/go-openapi/errors@v0.20.3 requires
        gopkg.in/check.v1@v1.0.0-20200227125254-8fa46927fb4f: unrecognized import path "gopkg.in/check.v1": reading https://gopkg.in/check.v1?go-get=1: 502 Bad Gateway
        server response: Cannot obtain refs from GitHub: cannot talk to GitHub: Get https://github.com/go-check/check.git/info/refs?service=git-upload-pack: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

It appears that it cannot reach out to the package to get the correct version (502) but also could be some sort of version mismatch in my go packages. Not sure how to resolve.

Here is my build command:

RUN cd /go/src/webservice_redfalcon/ && go mod init && go mod tidy && go mod download
RUN cd /go/src/webservice_redfalcon/cmd/redfalcon-server && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o /app/server

And my go version is 1.19

Any help would be much appreciated.

So the root issue appeared to be some sort of connectivity with github.com and retrieving the package. Once that networking issue was fixed then the 502 went away and it worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM