-
Notifications
You must be signed in to change notification settings - Fork 0
/
b11_basic_types.go
41 lines (37 loc) · 1.02 KB
/
b11_basic_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package basics
import (
"fmt"
"math/cmplx"
)
// https://tour.golang.org/basics/11
// Basic types
var (
toBe bool = false
maxInt uint64 = 1<<64 - 1
z complex128 = cmplx.Sqrt(-5 + 12i)
)
// Go's basic types are:
// bool
// string
// int int8 int16 int32 int64
// uint uint8 uint16 uint32 uint64 uintptr
// byte // alias for uint8
// rune // alias for int32
// // represents a Unicode code point
// float32 float64
// complex64 complex128
//
// The example shows variables of several types
// and also that variable declarations may be
// "factored" into blocks, as with import statements.
//
// The int, uint and uintptr types are usually
// 32 bits wide on 32-bit systems and 64 bits wide
// on 64-bit systems. When you need an integer
// value you should use int unless you have a specific
// reason to use a sized or unsigned integer type.
func BasicTypes() {
fmt.Printf("Type: %T Value: %v\n", toBe, toBe)
fmt.Printf("Type: %T Value: %v\n", maxInt, maxInt)
fmt.Printf("Type: %T Value: %v\n", z, z)
}