From charlesreid1

(Created page with "The hello world has three things you'll need to remember: * package main * import fmt * func main Here we go: <pre> // hello.go package main import "fmt" func main() {...")
 
No edit summary
 
Line 35: Line 35:
hello world
hello world
</pre>
</pre>
=Flags=
{{GoFlag}}

Latest revision as of 05:38, 11 December 2018

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