gomajor

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Direct

func Direct(dir string) ([]module.Version, error)

Direct returns a list of all modules that are direct dependencies

func FindModFile

func FindModFile(dir string) (string, error)

FindModFile recursively searches up the directory structure until it finds the go.mod, reaches the root of the directory tree, or encounters an error.

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 JoinPath

func JoinPath(modprefix, version, pkgdir string) string

JoinPath creates a full package path given a module prefix, version, and package directory.

func MaxVersion

func MaxVersion(v, w string) string

MaxVersion returns the larger of two versions according to semantic version precedence. 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 ModMajor

func ModMajor(modpath string) (string, bool)

ModMajor returns the major version in vN format

func ModPrefix

func ModPrefix(modpath string) string

ModPrefix returns the module path with no SIV

func NextMajor

func NextMajor(version string) (string, error)

NextMajor returns the next major version after the provided version

func SplitPath

func SplitPath(modprefix, pkgpath string) (modpath, pkgdir string, ok bool)

SplitPath splits the package path into the module path and the package subdirectory. It requires the a module path prefix to figure this out.

func SplitSpec

func SplitSpec(spec string) (path, query string)

SplitSpec splits the path/to/package@query format strings

Types

type Module

type Module struct {
	Path     string
	Versions []string
}

Module contains the module path and versions

func QueryCurrent added in v0.3.0

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

QueryCurrent finds the current major version of a module via go proxy. If the module does not exist, the second return parameter will be false cached sets the Disable-Module-Fetch: true header

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) WithMajorPath

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

WithMajorPath returns the module path for the provided version

type MultiModule added in v0.3.0

type MultiModule struct {
	// Modules is a list of modules with different major versions, in ascending order.
	Modules []*Module
}

MultiModule contains multiple modules with different major versions

func Query

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

Query finds the all versions of a module with major versions greater than or equal to current one. cached sets the Disable-Module-Fetch: true header

func (*MultiModule) Versions added in v0.3.0

func (mm *MultiModule) Versions() []string

type Update

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

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

Jump to

Keyboard shortcuts

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