common

package
v0.0.0-...-18b5139 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package implements functions to decode values of a html form.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataToStructByTagSql

func DataToStructByTagSql(data map[string]string, obj interface{})

根据结构体中sql标签映射数据到结构体中并且转换类型

func Decode

func Decode(vs url.Values, dst interface{}) error

Decode decodes the url.Values into a element that must be a pointer to a type provided by argument

func GetResultRow

func GetResultRow(rows *sql.Rows) map[string]string

获取返回值,获取一条

func GetResultRows

func GetResultRows(rows *sql.Rows) map[int]map[string]string

获取所有

func NewMysqlConn

func NewMysqlConn() (db *sql.DB, err error)

创建mysql 连接

func TypeConversion

func TypeConversion(value string, ntype string) (reflect.Value, error)

类型转换

Types

type DecodeCustomType

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

DecodeCustomType fields for custom types

type DecodeCustomTypeField

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

DecodeCustomTypeField is a function registered for a specific field of the struct passed to the Decoder

type DecodeCustomTypeFunc

type DecodeCustomTypeFunc func([]string) (interface{}, error)

DecodeCustomTypeFunc is a function that indicate how should to decode a custom type

type Decoder

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

Decoder the main to decode the values

func NewDecoder

func NewDecoder(opts *DecoderOptions) *Decoder

NewDecoder creates a new instance of Decoder

func (Decoder) Decode

func (dec Decoder) Decode(vs url.Values, dst interface{}) error

Decode decodes the url.Values into a element that must be a pointer to a type provided by argument

func (*Decoder) RegisterCustomType

func (dec *Decoder) RegisterCustomType(fn DecodeCustomTypeFunc, types []interface{}, fields []interface{}) *Decoder

RegisterCustomType It is the method responsible for register functions for decoding custom types

type DecoderOptions

type DecoderOptions struct {
	// TagName indicates the tag name for decoding a value by the tag
	TagName string
	// PrefUnmarshalText indicates if should to give preference to UnmarshalText over custom type registered
	PrefUnmarshalText bool
	// IgnoreUnknownKeys controls the behaviour when the decoder encounters unknown keys in the map. If i is true and an unknown field is encountered, it is ignored. This is similar to how unknown keys are handled by encoding/json. If i is false then Decode will return an error. Note that any valid keys will still be decoded in to the target struct.
	IgnoreUnknownKeys bool
}

DecoderOptions options for decoding the values

type Error

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

func (*Error) Cause

func (s *Error) Cause() error

Cause implements the causer interface from github.com/pkg/errors.

func (*Error) Error

func (s *Error) Error() string

func (Error) MarshalJSON

func (s Error) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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