golang数据类型

 1 /*
 2 
 3 类型 :
 4     bool
 5     string
 6     int、int8、int16、int32、int64
 7     uint、uint8、uint16、uint32、uint64、uintptr
 8     float32、float64
 9     complex64、complex128
10 
11 其它数字类型 :
12     byte : 类似 uint8
13     rune : 类似 int32
14     uint : 32 或 64 位
15     int : 与 uint 一样大小
16     uintptr : 无符号整型,用于存放一个指针
17 
18 数字类型 :
19     uint8 : 无符号 8 位整型 (0 到 255)
20     uint16 : 无符号 16 位整型 (0 到 65535)
21     uint32 : 无符号 32 位整型 (0 到 4294967295)
22     uint64 : 无符号 64 位整型 (0 到 18446744073709551615)
23 
24     int8 : 有符号 8 位整型 (-128 到 127)
25     int16 : 有符号 16 位整型 (-32768 到 32767)
26     int32 : 有符号 32 位整型 (-2147483648 到 2147483647)
27     int64 : 有符号 64 位整型 (-9223372036854775808 到 9223372036854775807)
28 
29 浮点型 :
30     float32 : IEEE-754 32位浮点型数
31     float64 : IEEE-754 64位浮点型数
32 
33     complex64 : 32 位实数和虚数
34     complex128 : 64 位实数和虚数
35 
36 派生类型 :
37     函数类型
38     指针类型(Pointer)
39     Channel 类型
40     数组类型
41     切片类型
42     Map 类型
43     结构化类型(struct)
44     接口类型(interface)
45 
46 定义接口interface : type 接口名 interface {方法名(参数列表) 返回值类型}
47     type personer interface {
48         show() string
49     }
50 
51 定义结构体struct : type 结构体名 struct {}(自定义数据类型)
52     type persons struct {
53         id int
54         name string
55     }
56     var user persons = persons{id:0, name:"lizi"}
57     user.age = 18; user.height = 150
58     fmt.Println(user)
59     fmt.Println(persons{1, "lizi", 20, 110})
60     fmt.Println(persons{id:2, name:"lizi", age:20, height:110})
61     fmt.Println(persons{id:3, name:"lizi"})
62 
63 
64 */
原文地址:https://www.cnblogs.com/weihexinCode/p/12317010.html