util

package
v6.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSONMarshal       = json.Marshal
	JSONUnmarshal     = json.Unmarshal
	JSONMarshalIndent = json.MarshalIndent
	JSONNewDecoder    = json.NewDecoder
	JSONNewEncoder    = json.NewEncoder
)

定义JSON操作

View Source
var (
	YAMLMarshal    = yaml.Marshal
	YAMLUnmarshal  = yaml.Unmarshal
	YAMLNewDecoder = yaml.NewDecoder
	YAMLNewEncoder = yaml.NewEncoder
)

定义YAML操作

Functions

func JSONMarshalToString

func JSONMarshalToString(v interface{}) string

JSONMarshalToString JSON编码为字符串

func MD5Hash

func MD5Hash(b []byte) string

MD5Hash MD5哈希值

func MD5HashString

func MD5HashString(s string) string

MD5HashString MD5哈希值

func SHA1Hash

func SHA1Hash(b []byte) string

SHA1Hash SHA1哈希值

func SHA1HashString

func SHA1HashString(s string) string

SHA1HashString SHA1哈希值

func StructMapToStruct

func StructMapToStruct(s, ts interface{}) error

StructMapToStruct 结构体映射

Types

type S

type S string

S 字符串类型转换

func (S) Bool

func (s S) Bool() (bool, error)

Bool 转换为bool

func (S) Bytes

func (s S) Bytes() []byte

Bytes 转换为[]byte

func (S) DefaultBool

func (s S) DefaultBool(defaultVal bool) bool

DefaultBool 转换为bool,如果出现错误则使用默认值

func (S) DefaultFloat32

func (s S) DefaultFloat32(defaultVal float32) float32

DefaultFloat32 转换为float32,如果出现错误则使用默认值

func (S) DefaultFloat64

func (s S) DefaultFloat64(defaultVal float64) float64

DefaultFloat64 转换为float64,如果出现错误则使用默认值

func (S) DefaultInt

func (s S) DefaultInt(defaultVal int) int

DefaultInt 转换为int,如果出现错误则使用默认值

func (S) DefaultInt64

func (s S) DefaultInt64(defaultVal int64) int64

DefaultInt64 转换为int64,如果出现错误则使用默认值

func (S) DefaultUint

func (s S) DefaultUint(defaultVal uint) uint

DefaultUint 转换为uint,如果出现错误则使用默认值

func (S) DefaultUint64

func (s S) DefaultUint64(defaultVal uint64) uint64

DefaultUint64 转换为uint64,如果出现错误则使用默认值

func (S) Float32

func (s S) Float32() (float32, error)

Float32 转换为float32

func (S) Float64

func (s S) Float64() (float64, error)

Float64 转换为float64

func (S) Int

func (s S) Int() (int, error)

Int 转换为int

func (S) Int64

func (s S) Int64() (int64, error)

Int64 转换为int64

func (S) String

func (s S) String() string

func (S) ToJSON

func (s S) ToJSON(v interface{}) error

ToJSON 转换为JSON

func (S) Uint

func (s S) Uint() (uint, error)

Uint 转换为uint

func (S) Uint64

func (s S) Uint64() (uint64, error)

Uint64 转换为uint64

Jump to

Keyboard shortcuts

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