test

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonColumn

type JsonColumn struct {
	Val   User // 存储解析后的json数据
	Valid bool // 标识json数据是否有效
}

JsonColumn 类型定义一个可以存储JSON数据的列。

func (*JsonColumn) Scan

func (j *JsonColumn) Scan(src any) error

Scan 方法实现将数据库查询结果的一列扫描到 JsonColumn 结构体中。 src 参数: 需要扫描的源数据,类型为 interface{},可以是 nil、字符串、字节切片或字节切片的指针。 返回值: 如果扫描成功,返回 nil;如果出现错误,返回相应的错误信息。

func (*JsonColumn) Value

func (j *JsonColumn) Value() (driver.Value, error)

Value 实现了将 JSON 数据转换为可以存储在数据库中的值。 此方法返回与 JSON 数据对应的数据库驱动值,如果数据无效则返回 nil。 参数:无 返回值:与 JSON 数据对应的数据库驱动值,或在转换失败时返回错误。

type SimpleStruct

type SimpleStruct struct {
	Id      uint64
	Bool    bool
	BoolPtr *bool

	Int    int
	IntPtr *int

	Int8    int8
	Int8Ptr *int8

	Int16    int16
	Int16Ptr *int16

	Int32    int32
	Int32Ptr *int32

	Int64    int64
	Int64Ptr *int64

	Uint    uint
	UintPtr *uint

	Uint8    uint8
	Uint8Ptr *uint8

	Uint16    uint16
	Uint16Ptr *uint16

	Uint32    uint32
	Uint32Ptr *uint32

	Uint64    uint64
	Uint64Ptr *uint64

	Float32    float32
	Float32Ptr *float32

	Float64    float64
	Float64Ptr *float64

	Byte      byte
	BytePtr   *byte
	ByteArray []byte

	String string

	// 特殊类型
	NullStringPtr *sql.NullString
	NullInt16Ptr  *sql.NullInt16
	NullInt32Ptr  *sql.NullInt32
	NullInt64Ptr  *sql.NullInt64
	NullBoolPtr   *sql.NullBool
	// NullTimePtr    *sql.NullTime
	NullFloat64Ptr *sql.NullFloat64
	JsonColumn     *JsonColumn
}

func NewSimpleStruct

func NewSimpleStruct(id uint64) *SimpleStruct

NewSimpleStruct 创建并返回一个新的 SimpleStruct 实例。 参数 id 被用作实例的唯一标识符。

type User

type User struct {
	Name string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL