【文件属性】:
文件名称:go-sizeof-tip:Go 类型的 Sizeof 提示
文件大小:2KB
文件格式:ZIP
更新时间:2021-07-03 16:29:33
Go
Go 类型的 Sizeof 提示
只是在组织结构时检查自己的一个小技巧。
import . "unsafe"
固定尺寸
类型
Sizeof()字节
struct{}
0
[0]Type
0
bool
1
int8 , uint8 , byte
1
int16 , uint16
2
int32 , uint32 , rune
4
float32
4
int , uint
4 或 8
int64 , uint64
8
float64
8
complex64
8
uintptr
8
*struct{} , *Type
8
map[Type1]Type2
8
chan Type
8
func()
8
string
16
complex128
16
[]Type
24
大批
公式: Sizeof([N]Type) = N
【文件预览】:
go-sizeof-tip-master
----.gitignore(6B)
----README.md(2KB)
----generate.go(5KB)