From charlesreid1

The hello world has three things you'll need to remember:

  • package main
  • import fmt
  • func main

Here we go:

// hello.go
package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

Now we run the program directly:

$ go run hello-world.go
hello world

or, use an intermediate compilation step:

$ go build hello-world.go
$ ls
hello-world	hello-world.go

$ ./hello-world
hello world


Flags