nan := math.NaN()
fmt.Println(nan == nan, nan < nan, nan > nan) // "false false false"
var x complex128 = complex(1, 2) // 1+2i
var y complex128 = complex(3, 4) // 3+4i
fmt.Println(x*y) // "(-5+10i)"
fmt.Println(real(x*y)) // "-5"
fmt.Println(imag(x*y)) // "10"
b := true
if b == 1 {} // compile error , Invalid operation: b == 1 (mismatched types bool and untyped int)
i := 1
if i {} // compile error , Non-bool 'i' (type int) used as condition
s := "left foot"
s[0] = 'L' // compile error: cannot assign to s[0]
const GoUsage = `Go is a tool for managing Go source code.
Usage:
go command [arguments]
...`
const entity = &Entity{Concurrent: 1} // compile error,Const initializer '&UploadLimitEntity{Concurrent: 1}' is not a constant
type Weekday int
const (
Sunday Weekday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
)
for name, age := range ages {
fmt.Printf("%s\t%d\n", name, age)
}
type Circle struct {
Point
Radius int
}
type Wheel struct {
Circle
Spokes int
}
var w Wheel
w.X = 8 // equivalent to w.Circle.Point.X = 8
w.Y = 8 // equivalent to w.Circle.Point.Y = 8
w.Radius = 5 // equivalent to w.Circle.Radius = 5
w.Spokes = 20