Linux command
go-run 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run Go file
go run [main.go]
Run package
go run .
Run with arguments
go run [main.go] [arg1] [arg2]
Run multiple files
go run [main.go] [helper.go]
说明
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.
参数
- -race
- Enable race detector.
- -exec _CMD_
- Execution wrapper.
- --help
- Display help information.
FAQ
What is the go-run command used for?
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.
How do I run a basic go-run example?
Run `go run [main.go]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -race do in go-run?
Enable race detector.