gotool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TempModfileBuildFlags

func TempModfileBuildFlags(projectDir string) (flags []string, cleanup func(), err error)

TempModfileBuildFlags returns go command flags that allow module graph updates without mutating the project's go.mod/go.sum.

This is primarily to make packages.Load work reliably even when the project module isn't tidy (for example, a freshly scaffolded module that only requires a local replace).

It returns flags suitable for packages.Config.BuildFlags:

  • -mod=mod
  • -modfile=<temp file>

Call cleanup after packages.Load completes.

Types

type CompatibilityError added in v0.1.0

type CompatibilityError struct {
	RequiredVersion  string
	RequiredBy       string
	EffectiveVersion string
	GOTOOLCHAIN      string
}

CompatibilityError reports a mismatched effective Go version.

func (*CompatibilityError) Error added in v0.1.0

func (e *CompatibilityError) Error() string

type Environment added in v0.1.0

type Environment struct {
	GOVERSION   string
	GOROOT      string
	GOTOOLCHAIN string
	GOPROXY     string
	GOSUMDB     string
	GOCACHE     string
	GOMODCACHE  string
	GOPATH      string
	GOMOD       string
	GOWORK      string
}

Environment captures relevant `go env` values.

type Report added in v0.1.0

type Report struct {
	ProjectDir    string
	GoModPath     string
	LauncherPath  string
	GoBinaryPath  string
	Requirements  Requirements
	Environment   Environment
	RequiredBy    string
	RequiredGoSem string
}

Report describes the effective Go toolchain for a project.

func Inspect added in v0.1.0

func Inspect(ctx context.Context, projectDir string, env []string) (*Report, error)

Inspect resolves the effective Go toolchain for a project and validates it against the project's go.mod requirements.

func (*Report) CommandContext added in v0.1.0

func (r *Report) CommandContext(ctx context.Context, dir string, env []string, args ...string) *exec.Cmd

CommandContext constructs a command that uses the resolved Go binary.

type Requirements added in v0.1.0

type Requirements struct {
	ModulePath string
	GoVersion  string
	Toolchain  string
}

Requirements captures version requirements declared in go.mod.

Jump to

Keyboard shortcuts

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