modproxy

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoVersions = errors.New("no module versions found")

ErrNoVersions is returned when the proxy has no version for a module

Functions

func CompareVersion

func CompareVersion(v, w string) int

CompareVersion returns -1 if v < w, 1 if v > w, and 0 if v == w Incompatible versions are considered lower than non-incompatible ones. Invalid versions are considered lower than valid ones. If both versions are invalid, the empty string is returned.

func IsNewerVersion

func IsNewerVersion(oldversion, newversion string, major bool) bool

IsNewerVersion returns true if newversion is greater than oldversion in terms of semver. If major is true, then newversion must be a major version ahead of oldversion to be considered newer.

func NextMajor

func NextMajor(version string) (string, error)

NextMajor returns the next major version after the provided version

func Private

func Private(modpath string) bool

Private reports whether the module bypasses the proxy. GONOPROXY defaults to GOPRIVATE when unset.

func Request

func Request(path string, cached bool) (*http.Response, error)

Request sends requests to the module proxies in order and returns the first 200 response.

func Updates

func Updates(opt UpdateOptions)

Updates finds updates for a set of specified modules.

Types

type Module

type Module struct {
	Path     string
	Versions []string
}

Module contains the module path and versions

func Latest

func Latest(modpath string, cached, pre bool) (*Module, error)

Latest finds the latest major version of a module cached sets the Disable-Module-Fetch: true header pre controls whether to return modules which only contain pre-release versions.

func List

func List(modpath string, cached bool) ([]*Module, error)

List finds all the major versions of a module cached sets the Disable-Module-Fetch: true header

func MaxVersion

func MaxVersion(mods []*Module, pre bool, r Retractions) (*Module, string)

MaxVersion returns the latest version of the module in the list. If pre is false, pre-release versions will are excluded. Retracted versions are excluded.

func Query

func Query(modpath string, cached bool) (*Module, bool, error)

Query the module proxy for all versions of a module. If the module does not exist, the second return parameter will be false. cached sets the Disable-Module-Fetch: true header.

func QueryPackage

func QueryPackage(pkgpath string, cached bool) (*Module, error)

QueryPackage tries to find the module path for the provided package path it does so by repeatedly chopping off the last path element and trying to use it as a path.

func (*Module) MaxVersion

func (m *Module) MaxVersion(prefix string, pre bool) string

MaxVersion returns the latest version. If there are no versions, the empty string is returned. Prefix can be used to filter the versions based on a prefix. If pre is false, pre-release versions will are excluded.

func (*Module) NextMajorPath

func (m *Module) NextMajorPath() (string, bool)

NextMajorPath returns the module path of the next major version

func (*Module) Retract

func (m *Module) Retract(r Retractions) *Module

Retract returns a copy of m with the retracted versions removed.

func (*Module) WithMajorPath

func (m *Module) WithMajorPath(version string) string

WithMajorPath returns the module path for the provided version

type Retractions

type Retractions []VersionRange

Retractions is a list of retracted versions.

func FetchRetractions

func FetchRetractions(mod *Module) (Retractions, error)

FetchRetractions fetches the retractions for this module.

func (Retractions) Includes

func (rr Retractions) Includes(v string) bool

Includes reports whether v is retracted

type Update

type Update struct {
	Module module.Version
	Latest module.Version
	Err    error
}

Update reports a newer version of a module. The Err field will be set if an error occured.

func (Update) MarshalJSON

func (u Update) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

type UpdateOptions

type UpdateOptions struct {
	Pre      bool
	Cached   bool
	Major    bool
	Modules  []module.Version
	OnUpdate func(Update)
}

UpdateOptions specifies a set of modules to check for updates. The OnUpdate callback will be invoked with any updates found.

type VersionRange

type VersionRange struct {
	Low, High string
}

VersionRange is an inclusive version range.

func (VersionRange) Includes

func (r VersionRange) Includes(v string) bool

Includes reports whether v is in the inclusive range

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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