Hello World
1
2
3
4
5
6
7
| package main
import "fmt"
func main() {
fmt.Printf("Hello, world or 你好,世界 or Καλημέρα κόσμε or こんにちは世界\n")
}
|
It prints following information.
Hello, world or 你好,世界 or Καλημέρα κόσμε or こんにちは世界
Define variables
1
2
3
4
5
6
7
8
9
| var variableName type = value
var vname1, vname2, vname3 type = v1, v2, v3
// Define three variables without type "type"
var vname1, vname2, vname3 = v1, v2, v3
vname1, vname2, vname3 := v1, v2, v3
_, b := 34, 35
|
Constants
1
2
3
4
5
6
7
| const constantName = value
// you can assign type of constants if it's necessary
const Pi float32 = 3.1415926
const Pi = 3.1415926
const i = 10000
const MaxThread = 10
const prefix = "astaxie_"
|
Elementary types