modcache

package
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package modcache implements ports.ModuleProxy against a local Go module cache ($GOMODCACHE) instead of a network module proxy. It is the proxy adapter used in --from-modcache mode.

The module cache stores the module-proxy protocol on disk:

$GOMODCACHE/cache/download/<escapedPath>/@v/<escapedVersion>.{info,mod,zip}

Info and Download read those files directly and compute h1 hashes from the bytes, exactly as the direct (network) proxy does. When an entry is missing — which should not happen after a build has populated the cache — the adapter shells out to `go mod download` to fetch it into the cache, then re-reads. No bytes are ever fetched over kanonarion's own HTTP client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is the module-cache-backed proxy adapter.

func New

func New(dir, goBinary, projectDir string, logger *slog.Logger) *Proxy

New constructs a module-cache proxy rooted at dir. goBinary may be empty (the adapter then uses "go" from PATH). projectDir is the module directory used as the working directory for any `go mod download` fallback; it may be empty, in which case the fallback runs in the process working directory.

func (*Proxy) Download

Download reads the module zip and go.mod from the cache (fetching them first if absent) and returns them with h1 hashes computed from the bytes.

func (*Proxy) DownloadGoMod

func (p *Proxy) DownloadGoMod(ctx context.Context, coord coordinate.ModuleCoordinate) (ports.GoModDownload, error)

DownloadGoMod reads only the module's go.mod from the cache (fetching it first if absent) and returns it with the h1 hash computed from the bytes. It is the go.mod-only counterpart to Download: it never reads or hashes the zip.

func (*Proxy) Info

Info returns the .info metadata for a module version, fetching it into the cache first if absent. Origin is always nil: VCS provenance is not tracked in module-cache mode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL