Go is a statically typed programming language. This means that variables always have a specific type and that type cannot change.
Integers
Generally if you are working with integers you should just use the int type.
Go's integer types are: uint8, uint16, uint32, uint64, int8, int16, int32 and int64. 8, 16, 32 and 64 tell us how many bits each of the types use.
uint means “un- signed integer” while int means “signed integer”. Un- signed integers only contain positive numbers (or zero).
In addition there two alias types: byte which is the same as uint8 and rune which is the same as int32.
There are also 3 machine de- pendent integer types: uint, int and uintptr. They are machine dependent because their size depends on the type of architecture you are using.
Floating Point Numbers
Go has two floating point types: float32 and float64
Example
package main
import "fmt"
func main() {
fmt.Println("1 + 1 =", 1 + 1)
}
If you run the program and you should see this:
$ go run main.go
1 + 1 = 2
Boolean
func main() {
fmt.Println(true && true)
fmt.Println(true && false)
fmt.Println(true || true)
fmt.Println(true || false)
fmt.Println(!true)
}
Running this program should give you:
$ go run main.go
true
false
true
true
false