gocmd

package
v28.4.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// CommandInstall represents go "install" command.
	CommandInstall = "install"

	// CommandGet represents go "get" command.
	CommandGet = "get"

	// CommandBuild represents go "build" command.
	CommandBuild = "build"

	// CommandMod represents go "mod" command.
	CommandMod = "mod"

	// CommandModTidy represents go mod "tidy" command.
	CommandModTidy = "tidy"

	// CommandModVerify represents go mod "verify" command.
	CommandModVerify = "verify"

	// CommandModDownload represents go mod "download" command.
	CommandModDownload = "download"

	// CommandFmt represents go "fmt" command.
	CommandFmt = "fmt"

	// CommandEnv represents go "env" command.
	CommandEnv = "env"

	// CommandList represents go "list" command.
	CommandList = "list"

	// CommandTest represents go "test" command.
	CommandTest = "test"

	// EnvGOARCH represents GOARCH variable.
	EnvGOARCH = "GOARCH"
	// EnvGOMOD represents GOMOD variable.
	EnvGOMOD = "GOMOD"
	// EnvGOOS represents GOOS variable.
	EnvGOOS = "GOOS"

	// FlagGcflags represents gcflags go flag.
	FlagGcflags = "-gcflags"
	// FlagGcflagsValueDebug represents debug go flags.
	FlagGcflagsValueDebug = "all=-N -l"
	// FlagLdflags represents ldflags go flag.
	FlagLdflags = "-ldflags"
	// FlagTags represents tags go flag.
	FlagTags = "-tags"
	// FlagMod represents mod go flag.
	FlagMod = "-mod"
	// FlagModValueReadOnly represents readonly go flag.
	FlagModValueReadOnly = "readonly"
	// FlagOut represents out go flag.
	FlagOut = "-o"
)

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, out, path string, flags []string, options ...exec.Option) error

Build runs go build on path with options.

func BuildPath

func BuildPath(ctx context.Context, output, binary, path string, flags []string, options ...exec.Option) error

BuildPath runs go install on cmd folder with options.

func BuildTarget

func BuildTarget(goos, goarch string) string

BuildTarget builds a GOOS:GOARCH pair.

func Env

func Env(name string) (string, error)

Env returns the value of `go env name`.

func Fmt

func Fmt(ctx context.Context, path string, options ...exec.Option) error

Fmt runs go fmt on path.

func Get

func Get(ctx context.Context, path string, pkgs []string, options ...exec.Option) error

Get runs go get pkgs on path with options.

func GoImports added in v28.2.0

func GoImports(ctx context.Context, path string) error

Imports runs goimports on path with options.

func Install

func Install(ctx context.Context, path string, pkgs []string, options ...exec.Option) error

Install runs go install pkgs on path with options.

func InstallAll

func InstallAll(ctx context.Context, path string, flags []string, options ...exec.Option) error

InstallAll runs go install ./... on path with options.

func IsInstallError

func IsInstallError(err error) bool

IsInstallError returns true if err is interpreted as a go install error.

func Ldflags

func Ldflags(flags ...string) string

Ldflags returns a combined ldflags set from flags.

func List

func List(ctx context.Context, path string, flags []string, options ...exec.Option) ([]string, error)

List returns the list of packages in path.

func ModDownload

func ModDownload(ctx context.Context, path string, json bool, options ...exec.Option) error

ModDownload runs go mod download on a path with options.

func ModTidy

func ModTidy(ctx context.Context, path string, options ...exec.Option) error

ModTidy runs go mod tidy on path with options.

func ModVerify

func ModVerify(ctx context.Context, path string, options ...exec.Option) error

ModVerify runs go mod verify on path with options.

func Name

func Name() string

Name returns the name of Go binary to use.

func PackageLiteral

func PackageLiteral(path, version string) string

PackageLiteral returns the string representation of package part of go get [package].

func ParseTarget

func ParseTarget(t string) (goos, goarch string, err error)

ParseTarget parses GOOS:GOARCH pair.

func Tags

func Tags(tags ...string) string

Tags returns a combined tags set from flags.

func Test added in v28.2.0

func Test(ctx context.Context, path string, flags []string, options ...exec.Option) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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