Skip to content

proposal: x/mod: create proxy package #73232

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

Open
jcbhmr opened this issue Apr 8, 2025 · 3 comments
Open

proposal: x/mod: create proxy package #73232

jcbhmr opened this issue Apr 8, 2025 · 3 comments
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Proposal
Milestone

Comments

@jcbhmr
Copy link

jcbhmr commented Apr 8, 2025

Proposal Details

Create a golang.org/x/mod/proxy package similar in goal to the golang.org/x/mod/sumdb package.

Why? To make it easy to setup, test, and develop your own https://modproxy.example.com/ Go module proxy for <meta name="go-import" content="example.com/awesome mod https://modproxy.example.com"> custom module proxies and/or GOPROXY=https://goproxy.example.com caching module proxies. I appreciate the https://pkg.go.dev/golang.org/x/mod/sumdb#Client and https://pkg.go.dev/golang.org/x/mod/sumdb#Server structs so that I can just plug-and-play some type MyServerOps struct {}, sumdb.NewServer(&MyServerOps{}) and then http.ListenAndServe(blahblah) and it works for testing. I also like being able to use a client very easily. I would appreciate a similar thing for module proxies.

This was mentioned in #31761:

golang.org/x/mod/proxy: go module proxy client and server protocol (like x/mod/sumdb; not written yet)

golang.org/x/mod/index: go module index client and server protocol (like x/mod/sumdb; not written yet)

golang.org/x/mod/gomodproxy: command: trivial go module proxy for reference and trivial uses (not published yet; maybe also “go mod proxy”)

So I think this isn't that far out. I am willing to contribute code to do this.

@jcbhmr jcbhmr added the Proposal label Apr 8, 2025
@gopherbot gopherbot added this to the Proposal milestone Apr 8, 2025
@gabyhelp gabyhelp added the LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool label Apr 8, 2025
@seankhliao
Copy link
Member

There are quite a few third party packages that already do this, for example https://pkg.go.dev/github.com/goproxy/goproxy
what does yet another implementation bring?

@jcbhmr
Copy link
Author

jcbhmr commented Apr 8, 2025

You're right that https://pkg.go.dev/github.com/goproxy/goproxy does offer a solution to GOPROXY=https://goproxy.example.com/ and maybe (unsure how well it works & fits) <meta name="go-import" content="example.com/awesome mod https://modproxy.example.com">.

That's one half you're right that can be left out. What about the client side of things? I really liked the symmetry of sumdb.Client and sumdb.Server. I liked the look of http://pkg.go.dev/cmd/go/internal/modfetch#Lookup (assuming I am able to provide a ClientOps thing like https://pkg.go.dev/golang.org/x/mod/sumdb#NewClient) and I was hoping that something like it could be exposed in x/mod/proxy or something alongside a basic server implementation (which you've pointed out now might be redundant) too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LibraryProposal Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool Proposal
Projects
None yet
Development

No branches or pull requests

4 participants