query

package
v0.0.0-...-4441722 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT, MIT Imports: 7 Imported by: 0

README

Build Status

query

query is Go library for encoding structs into URL query string.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversionError

type ConversionError struct {
	Key   string
	Type  reflect.Type
	Index int
	Err   error
}

ConversionError 存储了转换错误的详细信息

func (ConversionError) Error

func (e ConversionError) Error() string

type Converter

type Converter func(string) reflect.Value

Converter 转换函数

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder 将map[string][]string反编码为一个struct

func NewDecoder

func NewDecoder() *Decoder

NewDecoder 返回一个新的解码器

func (*Decoder) Decode

func (d *Decoder) Decode(src map[string][]string, dst interface{}) error

Decode 将一个map[string][]string解码为一个struct

func (*Decoder) IgnoreUnknownKeys

func (d *Decoder) IgnoreUnknownKeys(i bool)

IgnoreUnknownKeys 控制解码器遇到未知key时的行为

func (*Decoder) RegisterConverter

func (d *Decoder) RegisterConverter(value interface{}, converterFunc Converter)

RegisterConverter 为自定义类型注册一个转换函数

func (*Decoder) SetAliasTag

func (d *Decoder) SetAliasTag(tag string)

SetAliasTag 修改用来定位自定义字段别名的tag

func (*Decoder) ZeroEmpty

func (d *Decoder) ZeroEmpty(z bool)

ZeroEmpty 控制解码器遇到空值时的行为

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder 将一个struct编码为url.Values

func NewEncoder

func NewEncoder() *Encoder

NewEncoder 返回一个新的编码器

func (*Encoder) Encode

func (e *Encoder) Encode(src interface{}) (map[string][]string, error)

Encode 将一个struct编码为map[string][]string

func (*Encoder) RegisterEncoder

func (e *Encoder) RegisterEncoder(value interface{}, encoder func(reflect.Value) string)

RegisterEncoder 为自定义类型注册编码函数

func (*Encoder) SetAliasTag

func (e *Encoder) SetAliasTag(tag string)

SetAliasTag 用于修改用来定位自定义字段别名的tag

type MultiError

type MultiError map[string]error

MultiError 存储了多个编码或解码错误

func (MultiError) Error

func (e MultiError) Error() string

Jump to

Keyboard shortcuts

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