goutils

package module
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 26

README

go-utils

golang utils, it covers

Notes

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Base64Encode = base64.StdEncoding.EncodeToString
View Source
var HexEncode = hex.EncodeToString

Functions

func Absolute added in v1.5.7

func Absolute(_path string) string

func AssertEmpty added in v1.5.3

func AssertEmpty[T any](rest []T, message string)

func AssertNil added in v1.5.8

func AssertNil(i any, message string)

func AssertOK added in v1.6.0

func AssertOK(condition bool, message string)

func Atoi

func Atoi(str string) int

func Base64DecodeOrPanic added in v1.5.5

func Base64DecodeOrPanic(s string) []byte

func Deferred

func Deferred(handler DeferHandler, params ...interface{})

func Dirname added in v1.5.1

func Dirname() (string, error)

Dirname is the __dirname equivalent

func Filename added in v1.5.1

func Filename() (string, error)

Filename is the __filename equivalent

func FormatFloat

func FormatFloat(f float64, precision int) string

func FromJson

func FromJson(jsonString []byte, v interface{})

FromJson a wrapper to panic Unmarshal(non-pointer v)

func GetGoContext added in v1.5.2

func GetGoContext() context.Context

GetGoContext used by the initialization

func GetType added in v1.5.5

func GetType(object interface{}) string

func HexDecodeOrPanic added in v1.5.4

func HexDecodeOrPanic(s string) []byte

func HomeResolve added in v1.5.6

func HomeResolve(tokens ...string) string

func IsEmpty added in v1.5.10

func IsEmpty[T any](arr []T) bool

func ItoRunes

func ItoRunes(i int, runes []rune) string

func Map added in v1.5.6

func Map[T, V any](array []T, fn func(T) V) []V

func PaddingLeft

func PaddingLeft(str string, length int, pad rune) string

func PaddingRight

func PaddingRight(str string, length int, pad rune) string

func PanicError

func PanicError(err error)

func PanicString

func PanicString(err string)

func ParseFloat

func ParseFloat(str string) float64

func PrintError

func PrintError(err error)

func RandString

func RandString(length int, letterBytes string) string

RandString not thread safe

func ReadFile added in v1.5.1

func ReadFile(file string) ([]byte, error)

func ReadFileOrPanic added in v1.5.5

func ReadFileOrPanic(file string) []byte

func RoundFloat

func RoundFloat(num float64, precision int) float64

func ToInt

func ToInt(bytes []byte) int

func ToJson

func ToJson(v interface{}) []byte

Types

type DeferHandler

type DeferHandler func(err error, params ...interface{}) (success bool)

type TimeLong

type TimeLong int64

TimeLong unix nano

func (TimeLong) FromString

func (TimeLong) FromString(s string) TimeLong

func (TimeLong) FromTime

func (TimeLong) FromTime(t time.Time) TimeLong

func (TimeLong) FromUnixMilliSecond

func (TimeLong) FromUnixMilliSecond(t int64) TimeLong

func (TimeLong) String

func (t TimeLong) String() string

func (TimeLong) UnixMilliSecond

func (t TimeLong) UnixMilliSecond() int64

Directories

Path Synopsis
grpc module
leveldb module
logger module
orm module
restful module

Jump to

Keyboard shortcuts

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