utils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Timestamp please start the timer function before you use this value
	// please load the value with atomic `atomic.LoadUint32(&utils.Timestamp)`
	Timestamp uint32
)

Functions

func ByteSize

func ByteSize(bytes uint64) string

ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The unit that results in the smallest number greater than or equal to 1 is always chosen.

func CopyBytes

func CopyBytes(b []byte) []byte

CopyBytes copies a slice to make it immutable

func CopyString

func CopyString(s string) string

CopyString copies a string to make it immutable

func StartTimeStampUpdater

func StartTimeStampUpdater()

StartTimeStampUpdater starts a concurrent function which stores the timestamp to an atomic value per second, which is much better for performance than determining it at runtime each time

func ToString

func ToString(arg interface{}, timeFormat ...string) string

ToString Change arg to string

func UnsafeBytes

func UnsafeBytes(s string) (bs []byte)

#nosec G103 UnsafeBytes returns a byte pointer without allocation

func UnsafeString

func UnsafeString(b []byte) string

#nosec G103 UnsafeString returns a string pointer without allocation

Types

This section is empty.

Directories

Path Synopsis
The `fwd` package provides a buffered reader and writer.
The `fwd` package provides a buffered reader and writer.
This package is the support library for the msgp code generator (http://github.com/tinylib/msgp).
This package is the support library for the msgp code generator (http://github.com/tinylib/msgp).
xid
Package xid is a globally unique id generator suited for web scale
Package xid is a globally unique id generator suited for web scale
b

Jump to

Keyboard shortcuts

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