utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

func StringToBytes

func StringToBytes(s string) []byte

Types

type EasyMap

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

EasyMap 封装了一个类 map[string]interface{} 的数据结构, 提供了更加方便的方法来获取其中的字段值.

func EasyMapFromMap

func EasyMapFromMap(m map[string]interface{}) EasyMap

EasyMapFromMap 从 map[string]interface{} 创建一个 EasyMap.

参数:

m: 要封装的 map[string]interface{}, 不能为 nil

func (EasyMap) Get

func (m EasyMap) Get(key string) (interface{}, error)

Get 获取任意类型的字段值.

func (EasyMap) GetArray

func (m EasyMap) GetArray(key string) ([]interface{}, error)

GetArray 获取 []interface{} 类型的字段值.

func (EasyMap) GetBool

func (m EasyMap) GetBool(key string) (bool, error)

GetBool 获取布尔类型的字段值, 如果字段是字符串, 则会尝试转换.

func (EasyMap) GetBytes

func (m EasyMap) GetBytes(key string) ([]byte, error)

GetBytes 获取字节数组类型的字段值.

func (EasyMap) GetFloat64

func (m EasyMap) GetFloat64(key string) (float64, error)

GetFloat64 获取浮点数类型的字段值, 如果字段是字符串, 则会尝试转换.

func (EasyMap) GetInt64

func (m EasyMap) GetInt64(key string) (int64, error)

GetInt64 获取整数类型的字段值, 如果字段是字符串, 则会尝试转换.

func (EasyMap) GetMap

func (m EasyMap) GetMap(key string) (EasyMap, error)

GetMap 获取 map[string]interface{} 类型的字段值, 并封装为 EasyMap.

func (EasyMap) GetMapArray

func (m EasyMap) GetMapArray(key string) ([]EasyMap, error)

GetMapArray 获取 []map[string]interface{} 类型的字段值, 并封装为 []EasyMap.

func (EasyMap) GetString

func (m EasyMap) GetString(key string) (string, error)

GetString 获取字符串类型的字段值.

func (EasyMap) Set

func (m EasyMap) Set(key string, value interface{})

Set 设置任意类型的字段值.

func (EasyMap) Value

func (m EasyMap) Value() map[string]interface{}

Value 获取 EasyMap 内部数据结构的 map[string]interface{} 形式.

Jump to

Keyboard shortcuts

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