goproxy

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package goproxy provides pure helpers for interpreting the GOPROXY, GOPRIVATE and GONOPROXY environment variables the way the go command itself does. The parsing helpers are pure string -> value transforms; the per-spec module variables (GOPRIVATE and friends) ride on ctx, see WithSpecEnv.

Index

Constants

View Source
const DefaultProxyURL = "https://proxy.golang.org"

DefaultProxyURL is the module proxy the go command falls back to when GOPROXY is unset - https://proxy.golang.org.

Variables

This section is empty.

Functions

func Disabled

func Disabled(goproxy string) bool

Disabled reports whether goproxy's first entry is "off" - module downloading disabled entirely, per the go command's own convention.

func Environ added in v0.6.2

func Environ(ctx context.Context) []string

Environ returns KEY=value for every module variable, always all of them (empty when unset), so a go subprocess sees exactly ctx's values.

func FirstURL

func FirstURL(goproxy string) (string, bool)

FirstURL returns the first usable http(s) proxy URL named by a GOPROXY-style value. Only the first entry (before any "," or "|") is considered - there is no fallback-entry walking. An empty (or whitespace-only) goproxy reports Go's default proxy. A first entry of "direct", "off", or anything that doesn't parse as an http(s) URL with a host is reported as not-ok; it is up to the caller to decide what to do (fall back to a default, skip a probe, etc).

func Getenv added in v0.6.2

func Getenv(ctx context.Context, key string) string

Getenv returns key's value from ctx's spec environment when ctx carries one (see WithSpecEnv), else the process environment.

func IndexBaseURL

func IndexBaseURL(goproxy string) string

IndexBaseURL returns the base URL to query for the golang.org/toolchain release index: the first usable GOPROXY entry, falling back to Go's default public proxy when GOPROXY's first entry isn't directly usable (e.g. "direct", "off", or a private proxy this process can't reach unauthenticated). The toolchain index is public release metadata, so this fallback carries no privacy concern.

func IsPrivate

func IsPrivate(modulePath, goprivate, gonoproxy string) bool

IsPrivate reports whether modulePath should be treated as private, mirroring the go command's own precedence rule: when GONOPROXY is non-empty it governs exclusively; GOPRIVATE is only consulted as its default when GONOPROXY is empty. Patterns are matched with module.MatchPrefixPatterns, the same comma-separated glob matcher the go command itself uses for GOPRIVATE/GONOPROXY/GONOSUMCHECK.

func WithSpecEnv added in v0.6.2

func WithSpecEnv(ctx context.Context, spec map[string]string) context.Context

WithSpecEnv returns ctx carrying each module variable as the union of the process environment and spec (a melange spec's environment), comma-joined with empty values skipped, so a spec's private modules are treated as private by every go subprocess and module-name check run for it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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