mapx

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Copyright 2022 GoFast Author(http://chende.ren). All rights reserved. Use of this source code is governed by a MIT license

Index

Constants

View Source
const (
	LikeConfig int8 = iota // 采用解析配置文件的模式
	LikeInput              // 采用解析输入表单的模式
	LikeLoadDB             // 采用解析MySQL记录的模式
)

Variables

This section is empty.

Functions

func BindJsonBytes added in v0.4.4

func BindJsonBytes(dst any, content []byte, like int8) error

+++ JSON Bytes

func BindJsonBytesX added in v0.4.4

func BindJsonBytesX(dst any, content []byte, opts *BindOptions) error

func BindJsonReader added in v0.4.4

func BindJsonReader(dst any, reader io.Reader, like int8) error

+++ JSON Reader

func BindJsonReaderX added in v0.4.4

func BindJsonReaderX(dst any, reader io.Reader, opts *BindOptions) error

func BindKV added in v0.4.4

func BindKV(dst any, kvs cst.KV, like int8) error

NOTE(Important): 下面API中的第一个参数dst,最好都是指针类型,避免将来发生值拷贝

func BindKVX added in v0.4.4

func BindKVX(dst any, kvs cst.KV, opts *BindOptions) error

func BindSlice added in v0.4.4

func BindSlice(dst any, src any, like int8) error

func BindSliceX added in v0.4.4

func BindSliceX(dst any, src any, opts *BindOptions) error

func BindYamlBytes added in v0.4.4

func BindYamlBytes(dst any, content []byte, like int8) error

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func BindYamlBytesX added in v0.4.4

func BindYamlBytesX(dst any, content []byte, opts *BindOptions) error

func BindYamlReader added in v0.4.4

func BindYamlReader(dst any, reader io.Reader, like int8) error

func BindYamlReaderX added in v0.4.4

func BindYamlReaderX(dst any, reader io.Reader, opts *BindOptions) error

func Optimize added in v0.4.3

func Optimize(dst any, like int8) error

根据结构体配置信息,优化字段值 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

func OptimizeX added in v0.4.3

func OptimizeX(dst any, opts *BindOptions) error

func UnmarshalYamlBytes added in v0.4.4

func UnmarshalYamlBytes(dest any, content []byte) error

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yamlUnmarshal YAML to map[string]interface{} instead of map[interface{}]interface{}.

Types

type BindOptions added in v0.4.4

type BindOptions struct {
	FieldTag     string // 解析字段名对应的Tag标签
	ValidTag     string // 验证合法性对应的Tag标签
	CacheSchema  bool   // 是否缓存schema,提高性能
	UseFieldName bool   // 直接用字段名称,而不是通过 reflect tag 取名称
	UseDefValue  bool   // 默认不使用默认值
	UseValid     bool   // 默认不验证值规范
}

type StructSchema added in v0.4.4

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

表结构体Schema, 限制表最多127列(用int8计数)

func Schema

func Schema(obj any, opts *BindOptions) *StructSchema

cached

func SchemaNoCache

func SchemaNoCache(obj any, opts *BindOptions) *StructSchema

no cache

func SchemaNoCacheOfType added in v0.4.3

func SchemaNoCacheOfType(rTyp reflect.Type, opts *BindOptions) *StructSchema

func SchemaOfType

func SchemaOfType(rTyp reflect.Type, opts *BindOptions) *StructSchema

func (*StructSchema) AddrByIndex added in v0.4.4

func (ms *StructSchema) AddrByIndex(rVal *reflect.Value, index int8) any

func (*StructSchema) RefValueByIndex added in v0.4.4

func (ms *StructSchema) RefValueByIndex(rVal *reflect.Value, index int8) reflect.Value

func (*StructSchema) ValueByIndex added in v0.4.4

func (ms *StructSchema) ValueByIndex(rVal *reflect.Value, index int8) any

reflect

Jump to

Keyboard shortcuts

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