类型推导规则
- 整数 →
int或int64(可选) - 浮点数 →
float64 - 布尔 →
bool - 字符串 →
string(自动识别 RFC 3339 时间为time.Time) - null →
interface{}(推荐替换为指针类型如*string) - 对象 → 嵌套
struct或独立类型 - 数组 →
[]T(异构数组用[]interface{})
Go 命名规范
- 字段名转 PascalCase(首字母大写以导出)
- 常见缩写大写化:ID、URL、API、HTTP、JSON、XML、UUID、SQL
- JSON 字段名通过
json:"name"tag 保留原始命名 - 可选
,omitempty用于 marshal 时省略零值