LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

go-run

Compile and run Go programs

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 compiles to a temporary location and executes immediately, making it useful for rapid development and testing without creating a persistent binary.Any arguments after the package name are passed to the program. Standard build flags like `-race` and `-ldflags` are supported.

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.

INSTALL

sudo apt install gccgo-go
copy
sudo dnf install gcc-go
copy
sudo pacman -S gcc-go
copy
sudo apk add gcc-go
copy
sudo zypper install gcc-go
copy
brew install go
copy
nix profile install nixpkgs#go
copy

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)

RESOURCES

Copied to clipboard
Kai