Go与字段类型对应表

Go与字段类型对应表

如果不使用 tag 来定义 field 对应的数据库字段类型,那么系统会自动给出一个默认的字段类型,对应表如下:

go type's kindvalue methodxorm type
implemented ConversionConversion.ToDB / Conversion.FromDBText
int, int8, int16, int32, uint, uint8, uint16, uint32Int
int64, uint64BigInt
float32Float
float64Double
complex64, complex128json.Marshal / json.UnMarshalVarchar(64)
[]uint8Blob
array, slice, map except []uint8json.Marshal / json.UnMarshalText
bool1 or 0Bool
stringVarchar(255)
time.TimeDateTime
cascade structprimary key field valueBigInt
structjson.Marshal / json.UnMarshalText
OthersText