gomodupdates

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutdated = errors.New("outdated modules found")

ErrOutdated is returned when CI mode is enabled and at least one update is found.

Functions

func GoListModules

func GoListModules(ctx context.Context, goCommand, mod string) ([]byte, error)

GoListModules runs go list -u -m -json all and returns the JSON stream.

func RenderTable

func RenderTable(w io.Writer, rows []Row, opts Options)

RenderTable writes rows in the selected table format.

func Run

func Run(ctx context.Context, in io.Reader, out io.Writer, opts Options) error

Run converts go list -u -m -json all output into a table.

Types

type GoListError

type GoListError struct {
	Err    error
	Stderr string
}

GoListError wraps go list failures that include stderr.

func (*GoListError) Error

func (e *GoListError) Error() string

func (*GoListError) Unwrap

func (e *GoListError) Unwrap() error

type GoVersionLister

type GoVersionLister struct {
	GoCommand string
	Mod       string
}

GoVersionLister lists module versions by shelling out to go list.

func (GoVersionLister) Versions

func (l GoVersionLister) Versions(ctx context.Context, modulePath string) ([]string, error)

Versions returns versions for modulePath using go list -m -versions.

type MajorUpdate

type MajorUpdate struct {
	Path    string
	Version string
}

MajorUpdate is the latest discovered major module-path candidate.

func FindMajorUpdate

func FindMajorUpdate(ctx context.Context, modulePath, currentVersion string, lister VersionLister, limit int) (MajorUpdate, error)

FindMajorUpdate probes conventional semantic import version paths for a newer major module candidate.

func (MajorUpdate) String

func (u MajorUpdate) String() string

String returns the module path and version together because v2+ updates often require changing the import path.

type Module

type Module struct {
	Path      string       `json:",omitempty"`
	Version   string       `json:",omitempty"`
	Versions  []string     `json:",omitempty"`
	Replace   *Module      `json:",omitempty"`
	Time      *time.Time   `json:",omitempty"`
	Update    *Module      `json:",omitempty"`
	Main      bool         `json:",omitempty"`
	Indirect  bool         `json:",omitempty"`
	Dir       string       `json:",omitempty"`
	GoMod     string       `json:",omitempty"`
	Error     *ModuleError `json:",omitempty"`
	GoVersion string       `json:",omitempty"`
}

Module holds information for one module returned by go list -m -json.

func DecodeModules

func DecodeModules(in io.Reader) ([]Module, error)

DecodeModules decodes the JSON stream returned by go list -m -json.

func (Module) CurrentVersion

func (m Module) CurrentVersion() string

CurrentVersion returns the module version, accounting for replace directives.

func (Module) HasUpdate

func (m Module) HasUpdate() bool

HasUpdate reports whether the module has a same-path update.

func (Module) InvalidTimestamp

func (m Module) InvalidTimestamp() bool

InvalidTimestamp reports whether go list returned an update older than the current module version timestamp.

func (Module) NewVersion

func (m Module) NewVersion() string

NewVersion returns the same-path update version, accounting for replace directives.

type ModuleError

type ModuleError struct {
	Err string
}

ModuleError represents an error returned by go list for a module.

type Options

type Options struct {
	Update           bool
	Direct           bool
	Major            bool
	CI               bool
	Format           OutputFormat
	MajorLimit       int
	MajorConcurrency int
	Lister           VersionLister
}

Options configures module filtering and rendering.

type OutputFormat

type OutputFormat string

OutputFormat specifies the supported table rendering formats.

const (
	// FormatDefault is the default bordered table output.
	FormatDefault OutputFormat = "default"
	// FormatMarkdown is a Markdown table.
	FormatMarkdown OutputFormat = "markdown"
)

type Row

type Row struct {
	Module          string
	Version         string
	NewVersion      string
	Direct          bool
	ValidTimestamps bool
}

Row is a rendered module update row.

func Rows

func Rows(ctx context.Context, modules []Module, opts Options) ([]Row, error)

Rows filters modules and resolves optional major update candidates.

func (Row) HasUpdate

func (r Row) HasUpdate() bool

HasUpdate reports whether the row has an update.

type VersionLister

type VersionLister interface {
	Versions(ctx context.Context, modulePath string) ([]string, error)
}

VersionLister lists known versions for a module path.

Jump to

Keyboard shortcuts

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