Documentation
¶
Overview ¶
Package types 提供了一些实现了 sql.Scanner 和 driver.Valuer 接口的 实用类型,适合用作 database/sql 的扫描和赋值目标。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitBool ¶
type BitBool bool
BitBool 是 MySQL BIT(1) 类型的 bool 实现。 此类型使你可以避免为 MySQL 的布尔类型 TINYINT 浪费整个字节。
type GzippedText ¶
type GzippedText []byte
GzippedText 是一个 []byte,在提交到数据库时自动 gzip 压缩数据, 并在从数据库中 Scan 时自动解压数据。
func (*GzippedText) Scan ¶
func (g *GzippedText) Scan(src any) error
Scan 实现 sql.Scanner 接口,解压从网络传输过来的值, 并将原始结果存储在 GzippedText 中。
type JSONText ¶
type JSONText json.RawMessage
JSONText 是 json.RawMessage 的类型别名,底层是 []byte。 Value() 验证源数据中的 JSON 格式,如果 JSON 无效则返回错误。 Scan 不进行验证。JSONText 还实现了 Unmarshal 方法, 将内部的 JSON 反序列化到 any。
func (JSONText) MarshalJSON ¶
MarshalJSON 返回 *j 的 JSON 编码。
func (*JSONText) UnmarshalJSON ¶
UnmarshalJSON 将 *j 设置为 data 的副本。
type NullJSONText ¶
NullJSONText 表示一个可能为 null 的 JSONText。 NullJSONText 实现了 Scanner 接口,因此可以像 NullString 一样 用作扫描目标。
Click to show internal directories.
Click to hide internal directories.