gomodule

package
v29.0.0-...-a2903dc Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGoModNotFound returned when go.mod file cannot be found for an app.
	ErrGoModNotFound = errors.New("go.mod not found")

	// ErrModuleNotFound is returned when a Go module is not found.
	ErrModuleNotFound = errors.New("module not found")
)

Functions

func JoinPath

func JoinPath(path, version string) string

JoinPath joins a Go import path URI to a version. The result path have the "path@version" format.

func LocatePath

func LocatePath(ctx context.Context, cacheStorage cache.Storage, src string, pkg Version) (path string, err error)

LocatePath locates pkg's absolute path managed by 'go mod' on the local filesystem.

func ParseAt

func ParseAt(path string) (*modfile.File, error)

ParseAt finds and parses go.mod at app's path.

func SplitPath

func SplitPath(path string) (string, string)

SplitPath splits a Go import path into an URI path and version. Version is an empty string when the path doesn't contain a version suffix. Versioned paths use the "path@version" format.

Types

type Module

type Module struct {
	// Path is the Go module path.
	Path string

	// Version is the module version.
	Version string

	// Dir is the absolute path to the Go module.
	Dir string
}

Module contains Go module info.

func FindModule

func FindModule(ctx context.Context, rootDir, path string) (Module, error)

FindModule returns the Go module info for an import path. The module is searched within the dependencies of the module defined in root dir. If a local module path is passed, it returns the local module info.

type Version

type Version = module.Version

Version is an alias to the module version type.

func FilterVersions

func FilterVersions(dependencies []Version, paths ...string) []Version

FilterVersions filters dependencies under require section by their paths.

func ResolveDependencies

func ResolveDependencies(f *modfile.File, includeIndirect bool) ([]Version, error)

ResolveDependencies resolves dependencies from go.mod file. It replaces direct dependencies with their replacements.

Jump to

Keyboard shortcuts

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