gocandy

package module
v0.0.0-...-dcafb52 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 5 Imported by: 0

README

快速而又简单的Golang工具库

让开发更简单

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(val interface{}) (bool, error)

convert any value to bool Bool 将 val 转换成 bool 类型或是在无法转换的情况下返回 error。

123(true), 0(false),"-123"(true), "on"(true), "off"(false), "true"(true), "false"(false)

func Bytes

func Bytes(val interface{}) ([]byte, error)

convert any value to []byte Bytes 将 val 转换成 []byte 类型或是在无法转换的情况下返回 error。

func ContainsKey

func ContainsKey(val interface{}, subitem interface{}) (bool, error)

check if a key exists in array/slice/map does not support sub array 在array/slice/map中寻找键 不支持子数组

func ContainsValue

func ContainsValue(val interface{}, subitem interface{}) (bool, error)

check if a value exists in array/slice/map does not support sub array 在array/slice/map中寻找值 不支持子数组

func Float32

func Float32(val interface{}) (float32, error)

convert any value to float32 Float32 将 val 转换成 float32 类型或是在无法转换的情况下返回 error。

func Float64

func Float64(val interface{}) (float64, error)

convert any value to float64 Float64 将 val 转换成 float64 类型或是在无法转换的情况下返回 error。

func Implode

func Implode(listValue interface{}, glue string) (string, error)
Join array/map/slice elements with a string

将array/map/slice用给定的字符串连接

func Int

func Int(val interface{}) (int, error)

convert any value to int Int 将 val 转换成 int 类型或是在无法转换的情况下返回 error。

func Int32

func Int32(val interface{}) (int32, error)

convert any value to int32 Int32 将 val 转换成 int32 类型或是在无法转换的情况下返回 error。

func Int64

func Int64(val interface{}) (int64, error)

convert any value to int64 Int64 将 val 转换成 int64 类型或是在无法转换的情况下返回 error。

func Int8

func Int8(val interface{}) (int8, error)

convert any value to int8 Int8 将 val 转换成 int8 类型或是在无法转换的情况下返回 error。

func MustBool

func MustBool(val interface{}, def bool) bool

func MustBytes

func MustBytes(val interface{}, def []byte) []byte

func MustContainsKey

func MustContainsKey(val interface{}, subitem interface{}, def bool) bool

check if a key exists in array/slice/map, return def value in case error

func MustContainsValue

func MustContainsValue(val interface{}, subitem interface{}, def bool) bool

check if a value exists in array/slice/map, return def value in case error

func MustFloat32

func MustFloat32(val interface{}, def float32) float32

func MustFloat64

func MustFloat64(val interface{}, def float64) float64

func MustInt

func MustInt(val interface{}, def int) int

func MustInt32

func MustInt32(val interface{}, def int32) int32

func MustInt64

func MustInt64(val interface{}, def int64) int64

func MustInt8

func MustInt8(val interface{}, def int8) int8

func MustSlice

func MustSlice(val interface{}, def interface{}) interface{}

func MustString

func MustString(val interface{}, def string) string

convert any value to string or return del value in case of error

func MustUint

func MustUint(val interface{}, def uint) uint

func MustUint32

func MustUint32(val interface{}, def uint32) uint32

func MustUint64

func MustUint64(val interface{}, def uint64) uint64

func MustUint8

func MustUint8(val interface{}, def uint8) uint8

func Slice

func Slice(val interface{}) ([]interface{}, error)

func String

func String(val interface{}) (string, error)

convert any value to a string String 将 val 转换成 string 类型或是在无法转换的情况下返回 error。

func Substring

func Substring(source string, start int, end int) string

func Uint

func Uint(val interface{}) (uint, error)

convert any value to uint Uint 将 val 转换成 uint 类型或是在无法转换的情况下返回 error。

func Uint32

func Uint32(val interface{}) (uint32, error)

convert any value to uint32 Uint32 将 val 转换成 uint32 类型或是在无法转换的情况下返回 error。

func Uint64

func Uint64(val interface{}) (uint64, error)

convert any value to uint64 Uint64 将 val 转换成 uint64 类型或是在无法转换的情况下返回 error。 将一个有符号整数转换成无符号整数,负数将返回错误,正数和零正常转换

func Uint8

func Uint8(val interface{}) (uint8, error)

convert any value to uint8 Uint8 将 val 转换成 uint8 类型或是在无法转换的情况下返回 error。

Types

type GoMResult

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

func (*GoMResult) Bool

func (gmr *GoMResult) Bool(def bool) bool

format GoMResult to bool

func (*GoMResult) Bytes

func (gmr *GoMResult) Bytes(defautValue []byte) []byte

format GoMResult to []bytes

func (*GoMResult) Float32

func (gmr *GoMResult) Float32(defautValue float32) float32

format GoMResult to float32

func (*GoMResult) Float64

func (gmr *GoMResult) Float64(defautValue float64) float64

format GoMResult to float64

func (*GoMResult) Int

func (gmr *GoMResult) Int(def int) int

fotmat GoMResult to int

func (*GoMResult) Int64

func (gmr *GoMResult) Int64(defautValue int64) int64

format GoMResult to int64

func (*GoMResult) Int8

func (gmr *GoMResult) Int8(def int8) int8

format GoMResult to int8

func (*GoMResult) Interface

func (gmr *GoMResult) Interface() interface{}

get GoMResult as interface{}

func (*GoMResult) String

func (gmr *GoMResult) String(def string) string

format GoMResult to string

func (*GoMResult) Uint32

func (gmr *GoMResult) Uint32(defautValue uint32) uint32

format GoMResult to uint32

func (*GoMResult) Uint64

func (gmr *GoMResult) Uint64(defautValue uint64) uint64

format GoMResult to uint64

func (*GoMResult) Uint8

func (gmr *GoMResult) Uint8(defautValue uint8) uint8

format GoMResult to uint8

type GoMap

type GoMap struct {
	sync.RWMutex
	Map map[interface{}]interface{}
}

func NewMap

func NewMap() *GoMap

new a GoMap struct

func (*GoMap) Clear

func (gm *GoMap) Clear()

clear entire map and set to nil 清空整个map

func (*GoMap) Delete

func (gm *GoMap) Delete(key interface{})

delete a value from gomap 删除一条value值

func (*GoMap) Get

func (gm *GoMap) Get(keyname interface{}, def interface{}) *GoMResult

get a value from gomap 取得一条value值

func (*GoMap) KeyArray

func (gm *GoMap) KeyArray() []GoMResult

get the keys in list 获得所有的key 数组

func (*GoMap) Set

func (gm *GoMap) Set(keyname interface{}, val interface{})

set a value for gomap 设置一个map值

Directories

Path Synopsis
R

Jump to

Keyboard shortcuts

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