To install Go, follow the instructions on the official Go website: https://golang.org/dl/
To run a Go program, save the code in a file with a .go
extension (e.g., main.go
) and use the go run
command.
main.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
$ go run main.go
hello world