utils

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 11 Imported by: 8

Documentation

Overview

useful function, like UUID, Assert, Trace and more.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(err error)

Assert panic if err!=nil

func Trace

func Trace(prefix string) []string

Trace get call stack trace

func UUID

func UUID(n int, chars ...string) (string, error)

UUID generate random string with length n, chars of charmap, by default "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"

Types

type Bytes added in v1.0.7

type Bytes uint64

Bytes custom bytes struct

func (*Bytes) Bytes added in v1.0.7

func (data *Bytes) Bytes() uint64

Bytes get bytes data

func (Bytes) MarshalJSON added in v1.0.7

func (data Bytes) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes by json

func (*Bytes) MarshalKV added in v1.0.7

func (data *Bytes) MarshalKV() (string, error)

MarshalKV marshal bytes by kv

func (Bytes) MarshalYAML added in v1.0.7

func (data Bytes) MarshalYAML() (interface{}, error)

MarshalYAML marshal bytes by yaml

func (Bytes) Number added in v1.4.3

func (data Bytes) Number() uint64

Number get number

func (Bytes) String added in v1.0.7

func (data Bytes) String() string

String format to string

func (Bytes) Unit added in v1.4.2

func (data Bytes) Unit() string

Unit get unit

func (*Bytes) UnmarshalJSON added in v1.0.7

func (data *Bytes) UnmarshalJSON(value []byte) error

UnmarshalJSON unmarshal bytes by json

func (*Bytes) UnmarshalKV added in v1.0.7

func (data *Bytes) UnmarshalKV(value string) error

UnmarshalKV unmarshal bytes by kv

func (*Bytes) UnmarshalYAML added in v1.0.7

func (data *Bytes) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML unmarshal bytes by yaml

type Duration added in v1.0.7

type Duration time.Duration

Duration custom duration struct

func (Duration) Duration added in v1.0.7

func (d Duration) Duration() time.Duration

Duration get duration

func (Duration) MarshalKV added in v1.0.7

func (d Duration) MarshalKV() (string, error)

MarshalKV marshal duration

func (Duration) Number added in v1.4.3

func (d Duration) Number() uint64

Number get number

func (Duration) String added in v1.0.7

func (d Duration) String() string

String format to string

func (Duration) Unit added in v1.4.2

func (d Duration) Unit() string

Unit get unit

func (*Duration) UnmarshalKV added in v1.0.7

func (d *Duration) UnmarshalKV(value string) error

UnmarshalKV unmarshal duration

type Float64P2 added in v1.0.8

type Float64P2 float64

Float64P2 format yaml, json, kv string to 2 precision

func (Float64P2) Float added in v1.0.8

func (data Float64P2) Float() float64

Float get float64 data

func (Float64P2) MarshalJSON added in v1.0.8

func (data Float64P2) MarshalJSON() ([]byte, error)

MarshalJSON marshal float64 by json

func (Float64P2) MarshalKV added in v1.0.8

func (data Float64P2) MarshalKV() (string, error)

MarshalKV marshal float64 by kv

func (Float64P2) MarshalYAML added in v1.0.8

func (data Float64P2) MarshalYAML() (interface{}, error)

MarshalYAML marshal float64 by yaml

func (Float64P2) String added in v1.5.5

func (data Float64P2) String() string

String get string data

type Version added in v1.4.0

type Version [3]int

Version semantic version

func ParseVersion added in v1.4.0

func ParseVersion(str string) (Version, error)

ParseVersion parse semantic version string

func (Version) Equal added in v1.4.0

func (src Version) Equal(dst Version) bool

Greater validate src version is equal to dst version

func (Version) Greater added in v1.4.0

func (src Version) Greater(dst Version) bool

Greater validate src version is greater than dst version

func (Version) GreaterEqual added in v1.4.0

func (src Version) GreaterEqual(dst Version) bool

Greater validate src version is greater or equal dst version

func (Version) Less added in v1.4.0

func (src Version) Less(dst Version) bool

Greater validate src version is less than dst version

func (Version) LessEqual added in v1.4.0

func (src Version) LessEqual(dst Version) bool

Greater validate src version is less or equal dst version

func (Version) String added in v1.4.0

func (v Version) String() string

String show semantic version

Jump to

Keyboard shortcuts

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