mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-11 15:51:16 +00:00
Go Run
Inside hellogo, create a new file called main.go.
Conventionally, the file in the main package that contains the main() function is called main.go.
Paste the following code into your file:
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
Run the code
go run main.go
The go run command is used to quickly compile and run a Go package. The compiled binary is not saved in your working directory. Use go build instead to compile production executables.
I rarely use go run other than to quickly do some testing or debugging.
Further reading
Execute go help run in your shell and read the instructions.