util

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

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 21 Imported by: 7

README

Util

golang utilities

Usage

go get github.com/pilinsin/util
import(
  "github.com/pilinsin/util"
)

Documentation

Index

Constants

View Source
const Layout = "2006-1-2 15:4"

Variables

This section is empty.

Functions

func AddError

func AddError(err error, str string) error

func AnyBytes64ToStr

func AnyBytes64ToStr(b []byte) string

func AnyStrToBytes64

func AnyStrToBytes64(str string) []byte

func Arange

func Arange(start, stop, step int) []int

func ArangeStr

func ArangeStr(start, stop, step int) []string

func BoolPtr

func BoolPtr(b bool) *bool

func Bytes64ToAnyStr

func Bytes64ToAnyStr(b []byte) string

func BytesToReader

func BytesToReader(b []byte) io.Reader

func BytesToUint8s

func BytesToUint8s(bs []byte) []uint8

func CancelContext

func CancelContext() (context.Context, context.CancelFunc)

func CancelTimerContext

func CancelTimerContext(t time.Duration) (context.Context, context.CancelFunc)

func CheckError

func CheckError(err error)

func ConstTimeBytesEqual

func ConstTimeBytesEqual(b1, b2 []byte) bool

func ExeDirPath

func ExeDirPath() string

func GenRandomBytes

func GenRandomBytes(length int) []byte

func GenUniqueID

func GenUniqueID(length int, step int) string

func IntPtr

func IntPtr(n int) *int

func MapContainMap

func MapContainMap(m1, m2 map[string][]byte) bool

m1 > m2

func Marshal

func Marshal(objWithPublicMembers interface{}) ([]byte, error)

func NewContext

func NewContext() context.Context

func NewError

func NewError(a ...interface{}) error

func PathJoin

func PathJoin(base string, adders ...string) string

func PrintError

func PrintError(err error)

func RaiseError

func RaiseError(a ...interface{})

func RandInt

func RandInt(max int) int

only for 64bit

func ReaderToBytes

func ReaderToBytes(reader io.Reader) []byte

func SignalContext

func SignalContext() (context.Context, context.CancelFunc)

func StrPtr

func StrPtr(s string) *string

func StrSliceContain

func StrSliceContain(sl []string, elem string) bool

func StrToAnyBytes64

func StrToAnyBytes64(str string) []byte

func Uint8sToBytes

func Uint8sToBytes(u8s []uint8) []byte

func Unmarshal

func Unmarshal(b []byte, objWithPublicMembers interface{}) error

func WithSignal

func WithSignal(ctx context.Context) (context.Context, context.CancelFunc)

Types

type TimeInfo

type TimeInfo struct {
	Begin, End, Loc string
}

func NewTimeInfo

func NewTimeInfo(begin, end, loc string) (*TimeInfo, error)

func (TimeInfo) AfterTime

func (ti TimeInfo) AfterTime(now time.Time) bool

func (TimeInfo) BeginTime

func (ti TimeInfo) BeginTime() time.Time

func (TimeInfo) EndTime

func (ti TimeInfo) EndTime() time.Time

func (TimeInfo) WithinTime

func (ti TimeInfo) WithinTime(now time.Time) bool

Directories

Path Synopsis
aes

Jump to

Keyboard shortcuts

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