Skip to content

Fail to Go Install A Private Library

While GOPRIVATE is setup alrady, when tried to run go install, it reported error that verifying module failed as no such host while dial tcp.

$ go install doamin/pkg@v0.1.0
go: doamin/pkg@v0.1.0: doamin/pkg@v0.1.0: verifying module: doamin/pkg@v0.1.0: reading https://sum.golang.org/lookup/doamin/pkg@v0.1.0: 404 Not Found

    server response: not found: doamin/pkg@v0.1.0: unrecognized import path "doamin/pkg": https fetch: Get "https://doamin/pkg@v0.1.0?go-get=1": dial tcp: lookup doamin on 8.8.8.8:53: no such host
  • Verify git private is setup under ~/.gitconfig.
[url "git@domain:"]
    insteadOf = https://domain
  • check whether the metadata in the <header> part of response of get https://domain/pkg?go-get=1 is correct.
  • try go install -v -x domain/pkg@v0.1.0 &>> get.log.
# get https://domain/?go-get=1
# get https://domain/l1/l2?go-get=1
# get https://domain/l1?go-get=1
# get https://domain/l1/l2/pkg?go-get=1
# get https://domain/?go-get=1: 200 OK (0.010s)
# get https://domain/l1/l2?go-get=1: 200 OK (0.022s)
# get https://domain/l1?go-get=1: 200 OK (0.024s)
# get https://domain/l1/l2/pkg?go-get=1: 200 OK (0.040s)
WORK=/var/folders/6d/dh_qrvg967l_6r7lr00xf5940000gp/T/go-build1209949013:

Based on the logs above, it shows that the package is downloaded successfully, but fail to verify it.

Search more about why internal package need to be verified through https://sum.golang.org/lookup. Then find the solution that we could disable the verifiy by setting up export GOSUMDB=off.

Solution

export GOSUMDB=off to avoid verifying.