utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 8 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) String added in v1.0.7

func (data Bytes) String() string

String format to string

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) String added in v1.0.7

func (d Duration) String() string

String format to string

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

Jump to

Keyboard shortcuts

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