mod

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mod exposes methods to parse a go.mod file.

Index

Constants

View Source
const Filename = "go.mod"

Filename is the name of Go module file.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File is a go.mod file.

func Parse

func Parse(path string) (*File, error)

Parse tries to open a go.mod file.

func (*File) Dependencies

func (f *File) Dependencies() []Module

Dependencies implements the Mod interface.

func (*File) Format

func (f *File) Format() ([]byte, error)

Format implements the Mod interface.

func (*File) Module

func (f *File) Module() string

Module implements the Mod interface.

func (*File) Name

func (f *File) Name() string

Name implements the Mod interface.

func (*File) UpdateReplace

func (f *File) UpdateReplace(oldPath, newVersion string) error

UpdateReplace implements the Mod interface.

func (*File) UpdateRequire

func (f *File) UpdateRequire(path, version string) error

UpdateRequire implements the Mod interface.

type Mod

type Mod interface {
	// Module returns the name of the module.
	Module() string
	// Name returns the relative path of the go.mod
	Name() string
	// Dependencies returns the dependencies of the module.
	Dependencies() []Module
	// UpdateRequire adds an update of this required module path to the given version.
	UpdateRequire(path, version string) error
	// UpdateReplace adds an update on the replacement of this module path to the given version.
	UpdateReplace(oldPath, newVersion string) error
	// Format applies any requested updates to the file content.
	Format() ([]byte, error)
}

Mod represents a Go module file.

type Module

type Module interface {
	Indirect() bool
	Path() string
	Replacement() bool
	Version() semver.Tag
	ExcludeVersion() (v semver.Tag, ok bool)
}

Module represents a dependency.

type Parser

type Parser func(path string) (*File, error)

Parser defined the interface used to parse a go.mod file.

Jump to

Keyboard shortcuts

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