run go code
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Running Go Code and Explanation
$ go run main.go
Hello, World!
- We start by creating a file called
main.go
with the given Go code. - We use the
go run
command followed by the name of the Go file to execute the code. - The program outputs
Hello, World!
as expected.