upgrade

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package upgrade moves a project to another platform version.

The new version is required in go.mod, recorded in platformgo.yaml, and then applied by the new version itself through go tool: only it knows its generated files, its tools, its codemods and its checks. Afterwards the project is built, verified and tested. A dry run does all of it in a copy of the project and prints the plan.

Index

Constants

View Source
const Module = "github.com/aidarbn/platform-go"

Module is the Go module of the platform.

View Source
const Tool = Module + "/cmd/platformgo"

Tool is the package of the platform tool the project runs with go tool.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check added in v0.9.0

type Check struct {
	Name   string
	Args   []string // of the go command
	Err    error
	Output string // of a dry run
}

Check is a command run after the upgrade.

func Checks added in v0.9.0

func Checks() []Check

Checks are the commands that prove the upgraded project: it builds, its generation and manual steps are done, its tests pass.

type Options added in v0.9.0

type Options struct {
	Version string // a tag, or latest when empty
	DryRun  bool   // upgrade a copy of the project and print the plan; the project stays as it is
	NoCheck bool   // skip go build, platformgo verify and go test after the upgrade
	// Strict fails the upgrade when a check fails. Without it a failed check is a
	// warning and the upgrade succeeds, as it did before the checks existed.
	Strict bool
}

Options say how to upgrade.

type Result

type Result struct {
	From, To string
	Untidy   string  // go mod tidy -diff before the upgrade: what apply would tidy on top of it
	TidyErr  string  // go mod tidy -diff could not run: the reason
	Plan     string  // platformgo plan of the new version, in a dry run
	Checks   []Check // run after the upgrade
}

Result says what changed.

func Run

func Run(ctx context.Context, dir string, opts Options, run Runner, out io.Writer) (Result, error)

Run upgrades the project in dir.

func (Result) Failed added in v0.9.0

func (r Result) Failed() []string

Failed lists the checks that failed.

type Runner

type Runner func(ctx context.Context, dir string, out io.Writer, args ...string) error

Runner runs the go command in the project. Tests replace it.

Jump to

Keyboard shortcuts

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