Go 语言 FAQ
Table of Contents
1. map
1.1. Key
map 中的 key 必须是可以判定相等的类型。不建议把浮点数作为 key,最坏的情况下 NaN 和任何浮点数都不同。
1.2. 值还是引用?
map 是个引用类型(hash 表)。因此使用 map 必须初始化(否则值默认为 nil)。
1.3. 迭代
map 迭代顺序是不确定的。
2. json.marshal
[]byte
json marshal 会被自动做个 base64 编码,https://pkg.go.dev/encoding/json#Marshal
Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON value.