Go/Hello World: Difference between revisions
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
| Go notes on Go
Go/Strings · Go/Arrays · Go/Slices
Go/Lists · Go/Maps · Go/Stacks · Go/Queues
Go/Naming Conventions · Go/Design Patterns
Go/Timing · Go/Profiling · Go/Benchmarking
Go/Tests · Go/Travis CI · Go/Makefiles
our vim + go setup uses custom solarized colors for Golang
|