utils

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 16 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 BytesToString added in v1.0.8

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

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 ReadFile added in v1.0.8

func ReadFile(path string, fs http.FileSystem) ([]byte, error)

#nosec G304 ReadFile returns the raw content of a file

func SaveFile added in v1.0.8

func SaveFile(fh *multipart.FileHeader, path string) (err error)

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 StringToBytes added in v1.0.8

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation.

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

func Walk added in v1.0.8

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the filesystem rooted at root, calling walkFn for each file or directory in the filesystem, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order.

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