run

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(pkg string, opts ...RunOpt) *tools.CommandContext

Run compiles and runs the named main Go package. Typically the package is specified as a list of .go source files from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'.

The exit status of Run is not the exit status of the compiled binary.

func RunWithArgs

func RunWithArgs(pkg string, args []string, opts ...RunOpt) *tools.CommandContext

Run compiles and runs the named main Go package. Typically the package is specified as a list of .go source files from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'.

The exit status of Run is not the exit status of the compiled binary.

Types

type RunOpt

type RunOpt func(*runOptions)

func ASMFlags

func ASMFlags(value string) RunOpt

value '[pattern=]arg list' arguments to pass on each go tool asm invocation.

func BuildMode

func BuildMode(value string) RunOpt

build mode to use. See 'go help buildmode' for more.

func Compiler

func Compiler(value string) RunOpt

name of compiler to use, as in runtime.Compiler (gccgo or gc).

func EnableMemorySanitizer

func EnableMemorySanitizer() RunOpt

enable interoperation with memory sanitizer. Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used.

func Exec

func Exec(value string) RunOpt

By default, 'go run' runs the compiled binary directly: 'a.out arguments...'. If the -exec flag is given, 'go run' invokes the binary using xprog:

'xprog a.out arguments...'.

If the -exec flag is not given, GOOS or GOARCH is different from the system default, and a program named go_$GOOS_$GOARCH_exec can be found on the current search path, 'go run' invokes the binary using that program, for example 'go_js_wasm_exec a.out arguments...'. This allows execution of cross-compiled programs when a simulator or other execution method is available.

func ForceRebuild

func ForceRebuild() RunOpt

force rebuilding of packages that are already up-to-date.

func GCCFlags

func GCCFlags(value string) RunOpt

value '[pattern=]arg list' arguments to pass on each go tool compile invocation.

func GCCGoFlags

func GCCGoFlags(value string) RunOpt

value '[pattern=]arg list' arguments to pass on each gccgo compiler/linker invocation.

func InstallSuffix

func InstallSuffix(value string) RunOpt

a suffix to use in the name of the package installation directory, in order to keep output separate from default builds. If using the -race flag, the install suffix is automatically set to race or, if set explicitly, has _race appended to it. Likewise for the -msan flag. Using a -buildmode option that requires non-default compile flags has a similar effect.

func LDFlags

func LDFlags(value string) RunOpt

value '[pattern=]arg list' arguments to pass on each go tool link invocation.

func LinkShared

func LinkShared() RunOpt

build code that will be linked against shared libraries previously created with -buildmode=shared.

func Mod

func Mod(value string) RunOpt

module download mode to use: readonly, vendor, or mod. See 'go help modules' for more.

func ModCacheRW

func ModCacheRW() RunOpt

leave newly-created directories in the module cache read-write instead of making them read-only.

func ModFile

func ModFile(value string) RunOpt

in module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory. A file named "go.mod" must still be present in order to determine the module root directory, but it is not accessed. When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the ".mod" extension and appending ".sum".

func PackageDir

func PackageDir(value string) RunOpt

install and load all packages from dir instead of the usual locations. For example, when building with a non-standard configuration, use -pkgdir to keep generated packages in a separate location

func Race

func Race() RunOpt

enable data race detection. Supported only on linux/amd64, freebsd/amd64, darwin/amd64, windows/amd64, linux/ppc64le and linux/arm64 (only for 48-bit VMA).

func SetToolProvider

func SetToolProvider(p tools.ToolProvider) RunOpt

func SetToolVersion

func SetToolVersion(v string) RunOpt

func Tags

func Tags(value ...string) RunOpt

a comma-separated list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package. (Earlier versions of Go used a space-separated list, and that form is deprecated but still recognized.) NOTE: comma separation is handled automatically

func ToolExec

func ToolExec(value string) RunOpt

a program to use to invoke toolchain programs like vet and asm. For example, instead of running asm, the go command will run 'cmd args /path/to/asm <arguments for asm>'.

func TrimPath

func TrimPath() RunOpt

remove all file system paths from the resulting executable. Instead of absolute file system paths, the recorded file names will begin with either "go" (for the standard library), or a module path@version (when using modules), or a plain import path (when using GOPATH).

func Verbose

func Verbose() RunOpt

print the names of packages as they are compiled.

func Work

func Work() RunOpt

print the name of the temporary work directory and do not delete it when exiting.

func Workers

func Workers(value int) RunOpt

the number of programs, such as build commands or test binaries, that can be run in parallel. The default is the number of CPUs available.

Jump to

Keyboard shortcuts

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