# A Tour of Go
- go get golang.org/x/tour/gotour
- https://tour.golang.org/
# welcome
- fmt.Println("The time is", time.Now())
# basic
- Packages && Imports
- package main
- import (\n "fmt"\n "math"\n)
- fmt.Println("My favorite number is", rand.Intn(10))
- fmt.Println(math.Pi)
- Functions
- func add(x int, y int) int {
- func add(x, y int) int {
- Multiple results - func swap(x, y string) (string, string) {
- Named return values - func split(sum int) (x, y int) {
- Variables
- var c, python, java bool
- var c, python, java = true, false, "no!"
- Short variable declarations - k := 3
- bool、string、int8 uint16 uintptr、byte(uint8)、rune(int32)、float32 float64、complex64 complex128
- Zero values
- Variables declared without an explicit initial value are given their zero value.
- 0 for numeric types
- false for the boolean type
- "" (the empty string) for strings
- Type conversions
- i := 42
- f := float64(i)
- u := uint(f)
- Constants
- const World = "世界"
- const ( ... )