util

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(bytes []byte) string

BytesToString without copy

func GetFirstIP

func GetFirstIP() (string, error)

GetFirstIP gets the first IP of the current host

func GetFirstPrivateIP

func GetFirstPrivateIP() (string, error)

GetFirstPrivateIP gets the first private IP of the current host

func GetIPv4List added in v0.5.3

func GetIPv4List() ([]string, error)

GetIPv4List obtain all valid local addresses

func GetOneIP added in v0.5.3

func GetOneIP() (string, error)

GetOneIP obtain a valid ip address of the current host, with private ip preferred

func GetPrivateIPList

func GetPrivateIPList() ([]string, error)

GetPrivateIPList gets all the private IPs of the current host

func IPtoUInt

func IPtoUInt(ip string) uint32

IPtoUInt converts an IP to an uint64 integer

func IsPrivateIP

func IsPrivateIP(ip string) bool

IsPrivateIP checks if an IP is a private one, according to the tencent rules 内网保留IP参考KM: /q/view/210875

func JavaStringHash

func JavaStringHash(s string) uint32

JavaStringHash and Java String.hashCode() equivalent

func SnowFlakeID

func SnowFlakeID() string

SnowFlakeID generates a snowflake ID

func StringToBytes

func StringToBytes(str string) []byte

StringToBytes without copy

func UInt64UUID

func UInt64UUID() (uint64, error)

UInt64UUID generates an uint64 UUID

Types

type ExponentialBackoff

type ExponentialBackoff struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	Multiplier      float64
	Randomization   float64
}

ExponentialBackoff implements an exponential backoff strategy

func (*ExponentialBackoff) Next

func (b *ExponentialBackoff) Next(retryCount int) time.Duration

Next calculates the next interval with exponential backoff

Jump to

Keyboard shortcuts

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