utils

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KB = 1024.
	BytesUnitKB = 1024
	// MB = 1024 * KB.
	BytesUnitMB = 1024 * BytesUnitKB
	// GB = 1024 * MB.
	BytesUnitGB = 1024 * BytesUnitMB
)

Bytes Units.

Variables

This section is empty.

Functions

func ContainsCJKChar

func ContainsCJKChar(s string) bool

func Invoke0

func Invoke0(ctx context.Context, funcToBeRan func() error) error

func Print

func Print(inputs ...interface{})

Print 格式化输出所有传入的值的字段、值、类型、大小。

func PrintJSON

func PrintJSON(inputs ...interface{})

PrintJSON 格式化输出 JSON 格式。

func RandBytes

func RandBytes(length ...int) ([]byte, error)

RandBytes 根据给定的长度生成字节,长度默认为 32。

func RandomBase64Token

func RandomBase64Token(length ...int) (string, error)

RandomBase64Token 根据给定的字节长度生成 URL 安全的 Base64 字符串,长度默认为 32 长度为原始字节数据的长度,并非 Base64 字符串实际长度,默认 32 情况下实际长度约为 44。

func RandomHashString

func RandomHashString(length ...int) string

RandomHashString 生成随机 SHA256 字符串,最大长度为 64。

func RandomInt64

func RandomInt64(max ...int64) int64

RandomInt64 生成随机整数。

func RandomInt64InRange

func RandomInt64InRange(min, max int64) int64

RandomInt64InRange 在区间内生成随机整数。

func RandomInt64String

func RandomInt64String(digits int64) string

RandomInt64String 在区间内生成随机整数。

func ReadFileAsBytesBuffer

func ReadFileAsBytesBuffer(path string) (*bytes.Buffer, error)

func RelativePathBasedOnPwdOf

func RelativePathBasedOnPwdOf(fp string) string

func RelativePathOf

func RelativePathOf(fp string) string

RelativePathOf 获取基于调用函数的调用对象相对位置的相对路径。

func Sprint

func Sprint(inputs ...interface{}) string

Sprint 格式化输出所有传入的值的字段、值、类型、大小,并返回字符串。

NOTICE: 包含换行符。

func SprintJSON

func SprintJSON(inputs ...interface{}) string

SprintJSON 格式化输出 JSON 格式并返回字符串。

NOTICE: 包含换行符。

Types

This section is empty.

Jump to

Keyboard shortcuts

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