utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 8 Imported by: 0

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 AdaptiveMysqlDsn

func AdaptiveMysqlDsn(dsn string) string

AdaptiveMysqlDsn adaptation of various mysql format dsn address

func AdaptivePostgresqlDsn

func AdaptivePostgresqlDsn(dsn string) string

AdaptivePostgresqlDsn convert postgres dsn to kv string

func Float64ToStr

func Float64ToStr(v float64) string

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

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

SafeRun safe run

func SafeRunWithTimeout

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 StrToInt64

func StrToInt64(str string) int64

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