utils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstPromAppName                   = "app"
	ConstPrometheusNamespace           = "ginx"
	ConstPrometheusSubsystemName       = ""
	ConstHttpRequestIdleConnTimeout    = 15 * 1000
	ConstGrpcClientPingMinIntervalTime = 5 * 1000
)

Variables

View Source
var (
	PromAppName           = "default"
	InvalidIpAddressError = errors.New("invalid IP address")
)

Functions

func BytesToStr

func BytesToStr(b []byte) string

BytesToStr 字节转字符串

func CreateCtxWithTimeout

func CreateCtxWithTimeout(sec uint32) *context.Context

CreateCtxWithTimeout 创建 context

func GetCurrentMilliSecTimestamp

func GetCurrentMilliSecTimestamp() int64

func GetRand

func GetRand() *rand.Rand

func GetRandIdNumber

func GetRandIdNumber() int64

func Int64ToStr

func Int64ToStr(n int64) string

func IntToStr

func IntToStr(n int) string

func RemoveDuplicateUrlSlash

func RemoveDuplicateUrlSlash(s string) string

RemoveDuplicateUrlSlash 去除 url 中重复的 /

func RemoveDuplicateWhitespace

func RemoveDuplicateWhitespace(s string, trim bool) string

RemoveDuplicateWhitespace 删除字符串中重复的空白字符,只保留 为单个空白字符 trim: 是否去掉首位空白

func SetPromMetricsAppName

func SetPromMetricsAppName(name string)

func StrToBytes

func StrToBytes(s string) []byte

StrToBytes 字符串转字节

func TruncateDecimal4

func TruncateDecimal4(value float64) float64

TruncateDecimal4 uint 代表小数位数,格式位 0.000001 如果是几位就指定为几位

func Uint64ToStr

func Uint64ToStr(n uint64) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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