gomodule

package
v1.103.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(wd string) (int, error)

func GetLatestVersion

func GetLatestVersion(modulePath, workDir string) (string, error)

GetLatestVersion gets the latest version for a module with multiple fallback strategies

func TopologicalReleaseQueue

func TopologicalReleaseQueue(pkgs []*Package) ([]string, error)

TopologicalReleaseQueue performs a topological sort on the dependency graph and returns a slice of package names in release order while also modifying the pkgs slice.

Types

type BumpKind added in v1.100.0

type BumpKind string

BumpKind selects which version component a breaking change or Go version sync bumps - the release policy equivalent of "is this treated like a semver-major event, or does it stay within minor versions".

const (
	BumpKindMajor BumpKind = "major"
	BumpKindMinor BumpKind = "minor"
)

func ParseBumpKind added in v1.100.0

func ParseBumpKind(s string) (BumpKind, error)

ParseBumpKind validates s as a BumpKind.

type BumpStrategy added in v1.100.0

type BumpStrategy string

BumpStrategy selects how far a BumpKind bump advances that component.

const (
	// BumpStrategySingle advances the component by 1, e.g. 55 -> 56.
	BumpStrategySingle BumpStrategy = "single"
	// BumpStrategyHundred advances the component to the next full multiple
	// of 100 strictly greater than its current value, e.g. 55 -> 100,
	// 100 -> 200.
	BumpStrategyHundred BumpStrategy = "hundred"
	// BumpStrategyThousand advances the component to the next full
	// multiple of 1000 strictly greater than its current value, e.g.
	// 55 -> 1000, 1000 -> 2000.
	BumpStrategyThousand BumpStrategy = "thousand"
)

func ParseBumpStrategy added in v1.100.0

func ParseBumpStrategy(s string) (BumpStrategy, error)

ParseBumpStrategy validates s as a BumpStrategy.

type Dependency

type Dependency struct {
	Import     string
	UsedBy     []string
	MaxVersion version.Version
	MinVersion version.Version
}

func GetCommonDeps

func GetCommonDeps(pkgs []*Package) ([]Dependency, error)

type ModuleInfo

type ModuleInfo struct {
	Path      string `json:"Path"`
	Version   string `json:"Version"`
	Main      bool   `json:"Main"`
	Dir       string `json:"Dir,omitempty"`
	GoMod     string `json:"GoMod,omitempty"`
	GoVersion string `json:"GoVersion,omitempty"`
}

ModuleInfo represents the JSON output from go list -m -json

type Package

type Package struct {
	ModFilePath                string
	Dir                        string
	TagPrefix                  string
	Import                     string
	Modfile                    *modfile.File
	FirstRelease               bool
	NeedsRelease               bool
	PendingRelease             bool
	IsInternal                 bool
	UpdateDeps                 bool
	NextReleaseTag             string
	NextReleaseTagRemoteExists bool
	LastReleaseTag             string
	Changelog                  *changelog.Release
}

func Load

func Load(sess *session.Context, root, path string) (pkg *Package, err error)

func LoadAll

func LoadAll(sess *session.Context, wd string) ([]*Package, error)

func (*Package) ApplyTagTask

func (p *Package) ApplyTagTask(sess *session.Context, r *tr.Executor, dep tr.TaskID, prjwd string, internalDeps []*Package) tr.TaskID

func (*Package) GoModTidy

func (p *Package) GoModTidy(sess *session.Context) error

func (*Package) LoadReleaseInfo

func (p *Package) LoadReleaseInfo(sess *session.Context, rootPath, remoteName string, checkRemote bool, bumpKind BumpKind, bumpStrategy BumpStrategy) error

func (*Package) SetDep

func (p *Package) SetDep(dep string, ver version.Version) error

func (*Package) SyncGoVersion added in v1.1.0

func (p *Package) SyncGoVersion(rootGoVersion string, bumpKind BumpKind, bumpStrategy BumpStrategy) error

SyncGoVersion updates the module's go directive to match the root module's go version, so introducing a new Go-version-gated feature at the root (e.g. bumping to 1.27 for new generic methods) rolls out to every module in the monorepo on the next release, not just the ones whose own code happened to change. Must be called after LoadReleaseInfo, since it relies on LastReleaseTag and NextReleaseTag being populated.

A Go version sync is treated the same as a breaking change release-wise: it bumps bumpKind (advanced per bumpStrategy) rather than just a patch, since raising the minimum required Go version is itself the kind of significant, compatibility-affecting event bumpKind/bumpStrategy exist to express. That significant bump always wins over whatever ordinary (non-breaking) minor/patch bump getChangelog may have already computed from the package's own commits, since it's frequently the larger of the two - e.g. a plain feat commit's ordinary +1 minor bump must not stand in for a "jump straight to the next full hundred" Go version sync. The two candidates are compared explicitly (not just "is anything already set") so the actually-larger bump always wins, regardless of which one ran first.

func (*Package) SyncOwnGoVersion added in v1.100.0

func (p *Package) SyncOwnGoVersion(sess *session.Context, rootPath string, bumpKind BumpKind, bumpStrategy BumpStrategy) error

SyncOwnGoVersion is SyncGoVersion's counterpart for the root module itself: submodules sync to "the root's go version" via SyncGoVersion, but the root module has no external target to sync to - it defines its own go version. So instead this checks whether the go directive actually changed since the module's own LastReleaseTag, by diffing its go.mod against the copy recorded at that tag, and if so applies the same significant bump SyncGoVersion would.

Must be called after LoadReleaseInfo, since it relies on LastReleaseTag and NextReleaseTag being populated. Only meaningful for the root module (TagPrefix == ""); submodules should use SyncGoVersion instead.

Jump to

Keyboard shortcuts

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