#42

feat: add Go modules registry support

Openmvanhornwants to merge intofrom

Summary

Adds go: and golang: prefixes to fetch Go module source code via proxy.golang.org. Follows the existing registry pattern used by npm, PyPI, and crates.io.

Usage

opensrc path go:golang.org/x/tools
opensrc path golang:github.com/gin-gonic/gin
opensrc path go:golang.org/x/tools@v0.43.0

Also adds --go flag to opensrc clean and shows Go modules in opensrc list.

Demo

How it works

The Go module proxy at proxy.golang.org returns a JSON response with the canonical git repository URL in its Origin.URL field. For golang.org/x/* modules hosted on go.googlesource.com, the URL is rewritten to the official GitHub mirror at github.com/golang/* (the cache system expects host/owner/repo structure).

For modules without Origin data (older versions), the git URL is derived from the module path.

Changes

  • go.rs - New registry module: parse_go_spec and resolve_go_module following the existing pattern
  • mod.rs - Add Go variant to Registry enum, go: and golang: prefixes, extend parse_package_spec and resolve_package
  • main.rs - Add --go flag to clean command
  • list.rs - Add Go modules to the registries display and empty-state help text

Testing

8 new unit tests covering spec parsing, googlesource URL normalization, and module path resolution. All 40 tests pass (38 existing + 2 new googlesource tests + 6 existing Go tests = 40 with --test-threads=1).

cargo test --manifest-path packages/opensrc/cli/Cargo.toml -- --test-threads=1
cargo clippy --manifest-path packages/opensrc/cli/Cargo.toml -- -D warnings
cargo fmt --manifest-path packages/opensrc/cli/Cargo.toml --check

This contribution was developed with AI assistance (Claude Code).

Activity

6
vercel[bot]7mo ago

@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot]reviewed7mo ago