utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Overview

Package utils is a library of commonly used utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptiveMongodbDsn added in v1.6.1

func AdaptiveMongodbDsn(dsn string) string

AdaptiveMongodbDsn adaptive mongodb dsn

func AdaptiveMysqlDsn added in v1.5.16

func AdaptiveMysqlDsn(dsn string) string

AdaptiveMysqlDsn adaptation of various mysql format dsn address

func AdaptivePostgresqlDsn added in v1.5.16

func AdaptivePostgresqlDsn(dsn string) string

AdaptivePostgresqlDsn convert postgres dsn to kv string

func AdaptiveSqlite added in v1.6.1

func AdaptiveSqlite(dbFile string) string

AdaptiveSqlite adaptive sqlite

func GetAvailablePort

func GetAvailablePort() (int, error)

GetAvailablePort get available port

func GetHostname

func GetHostname() string

GetHostname get hostname

func GetLocalHTTPAddrPairs

func GetLocalHTTPAddrPairs() (serverAddr string, requestAddr string)

GetLocalHTTPAddrPairs get available http server and request address

func Int64ToStr

func Int64ToStr(v int64) string

Int64ToStr int64 to string

func IntToStr

func IntToStr(v int) string

IntToStr int to string

func SafeRun added in v1.2.0

func SafeRun(ctx context.Context, fn func(ctx context.Context))

SafeRun safe run

func SafeRunWithTimeout added in v1.2.0

func SafeRunWithTimeout(d time.Duration, fn func(cancel context.CancelFunc))

SafeRunWithTimeout safe run with limit timeouts

func StrToFloat32

func StrToFloat32(str string) float32

StrToFloat32 string to float32

func StrToFloat32E

func StrToFloat32E(str string) (float32, error)

StrToFloat32E string to float32 with error

func StrToFloat64

func StrToFloat64(str string) float64

StrToFloat64 string to float64

func StrToFloat64E

func StrToFloat64E(str string) (float64, error)

StrToFloat64E string to float64 with error

func StrToInt

func StrToInt(str string) int

StrToInt string to int

func StrToIntE

func StrToIntE(str string) (int, error)

StrToIntE string to int with error

func StrToUint32

func StrToUint32(str string) uint32

StrToUint32 string to uint32

func StrToUint32E

func StrToUint32E(str string) (uint32, error)

StrToUint32E string to uint32 with error

func StrToUint64

func StrToUint64(str string) uint64

StrToUint64 string to uint64

func StrToUint64E

func StrToUint64E(str string) (uint64, error)

StrToUint64E string to uint64 with error

func Uint64ToStr

func Uint64ToStr(v uint64) string

Uint64ToStr uint64 to string

Types

This section is empty.

Jump to

Keyboard shortcuts

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