types

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppletTimeFormat 小程序时间格式
	AppletTimeFormat = "2006-01-02T15:04:05.000Z"
)

Variables

View Source
var BoolName = map[Bool]string{
	False: "FALSE",
	True:  "TRUE",
	Any:   "ANY",
}

BoolName 对应关系

Functions

func ContainsString

func ContainsString(arr []string, str string) bool

ContainsString 判断字符串是否在字符串数组中

func Float32

func Float32(v float32) *float32

func Float64

func Float64(v float64) *float64

func GenerateID

func GenerateID() string

GenerateID 生成ID

func InStringSlice

func InStringSlice(str string, arr []string) bool

InStringSlice 判断字符串是否在字符串数组中

func InUintSlice

func InUintSlice(num uint, arr []uint) bool

InUintSlice 判断整数是否在整数数组中

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func Int64

func Int64(v int64) *int64

func Int8

func Int8(v int8) *int8

func MustString

func MustString(s interface{}) string

MustString 将任意类型转换为字符串

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Time

func Time(t time.Time) *time.Time

Time time.Time

func Uint

func Uint(v uint) *uint

Uint is a helper routine that allocates a new uint32 value to store v and returns a pointer to it, but unlike Uint32 its argument value is an int.

func Uint8

func Uint8(v uint8) *uint8

Types

type AppletTime

type AppletTime time.Time

小程序时间

func (AppletTime) MarshalJSON

func (t AppletTime) MarshalJSON() ([]byte, error)

MarshalJSON 实现json序列化接口

func (AppletTime) String

func (t AppletTime) String() string

String 实现string接口

func (AppletTime) Time

func (t AppletTime) Time() time.Time

Time 转换为time.Time

func (*AppletTime) UnmarshalJSON

func (t *AppletTime) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现json反序列化接口

type Bool

type Bool int32

Bool gorm bool gorm:"column:xxxx;type:TINYINT;default:-1"

const (
	// False .
	False Bool = -1
	// True .
	True Bool = 1
	// Any .
	Any Bool = 2
)

func NewBool

func NewBool(v bool) Bool

New ...

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON .

func (Bool) MarshalYAML

func (b Bool) MarshalYAML() (interface{}, error)

MarshalYAML .

func (Bool) ToString

func (x Bool) ToString() string

ToString .

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON .

func (*Bool) UnmarshalYAML

func (b *Bool) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML .

func (Bool) Value

func (b Bool) Value() bool

Value ...

type Money

type Money float64

Money 金钱类型

func NewMoney

func NewMoney(a float64) Money

func (Money) Abs

func (m Money) Abs() Money

Abs 求绝对值

func (Money) Add

func (m Money) Add(a Money) Money

Add .

func (Money) Ceil

func (m Money) Ceil() Money

Ceil 向上取整

func (Money) Div

func (m Money) Div(a float64) Money

Div .

func (Money) Equal

func (m Money) Equal(b Money) bool

Equal =

func (Money) Floor

func (m Money) Floor() Money

Floor 向下取整

func (Money) GreaterZero

func (m Money) GreaterZero() bool

GreaterZero 是否大于0

func (Money) IsZero

func (m Money) IsZero() bool

IsZero 是否为0

func (Money) Less

func (m Money) Less(a Money) bool

Less <

func (Money) LessZero

func (m Money) LessZero() bool

LessZero 是否小于0

func (Money) MarshalJSON

func (m Money) MarshalJSON() ([]byte, error)

MarshalJSON .

func (Money) Mul

func (m Money) Mul(a float64) Money

Mul .

func (Money) String

func (m Money) String() string

1.00499

func (Money) Sub

func (m Money) Sub(a Money) Money

Sub .

func (Money) ToUpper

func (m Money) ToUpper() string

ToUpper 人民币大写

func (Money) Val

func (m Money) Val() float64

Val .

type Password

type Password string

Password 密码

type SafeID

type SafeID uint

SafeID 是一个安全的ID

func (*SafeID) Dec

func (id *SafeID) Dec(idstr string)

func (SafeID) Enc

func (id SafeID) Enc() string

Enc 加密的ID

func (SafeID) MarshalJSON

func (id SafeID) MarshalJSON() ([]byte, error)

MarshalJSON .

func (*SafeID) UnmarshalJSON

func (id *SafeID) UnmarshalJSON(data []byte) error

UnmarshalJSON .

type Secret

type Secret string

func (Secret) Dec

func (s Secret) Dec() Secret

Dec 解密

func (Secret) Enc

func (s Secret) Enc() Secret

Enc 加密

type StringArray

type StringArray string

StringArray 字符串数组,用于Mysql数据库和接口之间的转换

func New

func New(v ...string) StringArray

func (StringArray) First

func (i StringArray) First() string

func (StringArray) MarshalJSON

func (i StringArray) MarshalJSON() ([]byte, error)

MarshalJSON .

func (StringArray) MarshalYAML

func (i StringArray) MarshalYAML() (interface{}, error)

MarshalYAML .

func (StringArray) Slice

func (i StringArray) Slice() (arr []string)

Slice .

func (*StringArray) UnmarshalJSON

func (i *StringArray) UnmarshalJSON(data []byte) error

UnmarshalJSON .

func (*StringArray) UnmarshalYAML

func (i *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML .

Jump to

Keyboard shortcuts

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