Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for privately hosted go modules #182

Open
drewwells opened this issue May 24, 2021 · 3 comments
Open

Instructions for privately hosted go modules #182

drewwells opened this issue May 24, 2021 · 3 comments

Comments

@drewwells
Copy link

drewwells commented May 24, 2021

It is clear that goproxy can be used for private repositories, but it is unclear how to correctly set this up. I have put goproxy on a computer with full ssh access (and populated GOPATH). I am able to use this to pull code from a machine without private repo access, but there's some caveats with it.

The client computer didn't appear to use the proxy if it could call git directly. So I removed ssh credentials to prevent this path. If I don't specify --insecure, then go get fails on sumdb checks.

This does not work, fails on sumdb

GONOPROXY=github.com/myorg GONOSUMDB=github.com/myorg go run *.go -listen=0.0.0.0:8082 -exclude "github.com/myorg" -proxy http://nope.nope
-> % GOPROXY=http://192.127.1.25:8082 go get -d -v github.com/myorg/[email protected]
github.com/myorg/[email protected]: verifying module: github.com/myorg/[email protected]: reading http://192.127.1.25:8082/sumdb/sum.golang.org/lookup/github.com/myorg/[email protected]: 410 Gone
	server response: not found: github.com/myorg/[email protected]: invalid version: unknown revision v1.6.4

Disabling sumdb checks makes it work

GOPROXY=http://192.127.1.25:8082 go get --insecure -d -v github.com/myorg/[email protected]
go get: -insecure flag is deprecated; see 'go help get' for details
go: downloading github.com/myorg/myrepo v1.6.4
@ArnoSen
Copy link

ArnoSen commented Sep 6, 2021

I am running into similar issues but not always.
The public sumdb is used for private repositories (e.g. repositories under --exclude).
Documentation on how to configure for internally hosted repositories is more than welcome.

Sometimes I need to restart the service a few times and then suddenly it starts to function.
Since this issue is stale for 3.5 months, I wonder if this repo is still supported in any way.

@ArnoSen
Copy link

ArnoSen commented Sep 10, 2021

After further investigation, I found out that most of the issues I was running was caused by:

  • using an older version of go (1.13.8) which has less specific error messages compared to version 1.16.7 that I am running right now. With the better error reporting I was able to solve the issues I had and it looks like to be stable now
  • apparently I was not following the right procedure to update a dependency. How I always did it was changing the version in go.mod and that was it. The effect was however that the has in go.sum was not updated and the build on the build server would fail with a bad gateway error. The right procedure is to run a go get <dependency name> which updates both go.mod and go.sum .
  • I did not retest it but I think it is necessary to add the wildcard (*) to the exclude repos that is put a flags to starting the goproxy service. If the wildcard is not there, it looks like goproxy treats my dependency as an external one instead of a private rep.

I hope this feedback is useful.

@jianzhiyao
Copy link

I meet that issue also, it's running good after setting GOPRIVATE on proxy machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants