Documentation
¶
Index ¶
- func Run(pkg string, opts ...RunOpt) *tools.CommandContext
- func RunWithArgs(pkg string, args []string, opts ...RunOpt) *tools.CommandContext
- type RunOpt
- func ASMFlags(value string) RunOpt
- func BuildMode(value string) RunOpt
- func Compiler(value string) RunOpt
- func EnableMemorySanitizer() RunOpt
- func Exec(value string) RunOpt
- func ForceRebuild() RunOpt
- func GCCFlags(value string) RunOpt
- func GCCGoFlags(value string) RunOpt
- func InstallSuffix(value string) RunOpt
- func LDFlags(value string) RunOpt
- func LinkShared() RunOpt
- func Mod(value string) RunOpt
- func ModCacheRW() RunOpt
- func ModFile(value string) RunOpt
- func PackageDir(value string) RunOpt
- func Race() RunOpt
- func SetToolProvider(p tools.ToolProvider) RunOpt
- func SetToolVersion(v string) RunOpt
- func Tags(value ...string) RunOpt
- func ToolExec(value string) RunOpt
- func TrimPath() RunOpt
- func Verbose() RunOpt
- func Work() RunOpt
- func Workers(value int) RunOpt
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 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 ¶
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 GCCGoFlags ¶
value '[pattern=]arg list' arguments to pass on each gccgo compiler/linker invocation.
func InstallSuffix ¶
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 LinkShared ¶
func LinkShared() RunOpt
build code that will be linked against shared libraries previously created with -buildmode=shared.
func ModCacheRW ¶
func ModCacheRW() RunOpt
leave newly-created directories in the module cache read-write instead of making them read-only.
func ModFile ¶
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 ¶
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 Tags ¶
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 ¶
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).