LinuxCommandLibrary

go-run

TLDR

Run Go file

$ go run [main.go]
copy
Run package
$ go run .
copy
Run with arguments
$ go run [main.go] [arg1] [arg2]
copy
Run multiple files
$ go run [main.go] [helper.go]
copy

SYNOPSIS

go run [options] package [arguments]

DESCRIPTION

go run compiles and runs a Go program in one step. It's useful for development and testing, combining build and execute without creating a binary.
The command compiles to a temporary location and executes. Any arguments after the package name are passed to the program. Build flags are supported.
go run provides rapid compile-and-run development.

PARAMETERS

PACKAGE

Go files or package to run.
ARGUMENTS
Arguments passed to program.
-race
Enable race detector.
-exec CMD
Execution wrapper.
--help
Display help information.

CAVEATS

Slower than running compiled binary. Temporary binary not retained. Useful for development.

HISTORY

go run is part of the Go toolchain, providing convenient rapid iteration during development.

SEE ALSO

go(1), go-build(1)

Copied to clipboard