goproxy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package goproxy provides pure helpers for interpreting the GOPROXY, GOPRIVATE and GONOPROXY environment variables the way the go command itself does. Callers read the environment once at a construction site (os.Getenv) and pass the resulting values in; every function here is a pure string -> value transform so it stays hermetic to test.

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 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 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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