private repo - go 1.13 - `go mod ..` failed: ping “sum.golang.org/lookup” .. verifying package .. 410 gone

前端 未结 4 503
野性不改
野性不改 2021-02-03 21:11

I am using golang 1.13 .

I have a project that depends on a private gitlab project.

I have the ssh keys for the same.

When I try to retrieve the depen

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 21:58

    Basically it failed to verify private repository. However I don't like turning off checksum, but you can easily set GOSUMDB to off before trying to get module. something like this:

    GOSUMDB=off go get github.com/mycompany/myproject
    

    ref: https://github.com/golang/go/issues/35164#issuecomment-546503518

    A second and better solution is to set GOPRIVATE environment variable that controls which modules the go command considers to be private (not available publicly) and should therefore NOT use the proxy or checksum database. The variable is a comma-separated list of glob patterns (same syntax of Go's path.Match) of module path prefixes. For example,

    export GOPRIVATE=*.corp.example.com,rsc.io/private
    

    Or

    go env -w GOPRIVATE=github.com/mycompany/*
    

    Last solution you can try is to turn off such checks for all private repositories that you don't want to go public or being verified through sum.golang.org/lookup/github.com/mycompany/...

    GONOSUMDB=gitlab.com/mycompany/* go mod why
    

    Note that:

    If you have issues fetching modules or repos over https, you may want to add the following to your ~/.gitconfig to make go get/fetch repositories using ssh instead of https

    [url "ssh://git@github.com/"] insteadOf = https://github.com/

提交回复
热议问题