Documentation ¶
Index ¶
- Constants
- Variables
- func CatchPanic(title string)
- func CopyFile(dest, source string) error
- func GetCallStackNames(skip, limit int) []string
- func GetEnv(key string, def string) string
- func GetEnvBool(key string) bool
- func GetEnvFloat(key string, def float64) float64
- func GetEnvInt(key string, def int) int
- func GetEnvInt64(key string, def int64) int64
- func GetProjRootDir() string
- func GetProjRootDirOf(path string) string
- func IsFileExist(filename string) bool
- func IsFileNotExist(filename string) bool
- func IsProjRootDir(path string) bool
- func JSONParse(s string, v any) error
- func JSONStringify(v any) string
- func LoadDotEnv(filenames ...string) error
- func MD5Sum(data []byte) string
- func MapAdd[M ~map[K]V, K comparable, V cmp.Ordered](a, b M) M
- func MapIntersect[M ~map[K]V, K, V comparable](a, b M) M
- func MapKeyValues[M ~map[K]V, K comparable, V any](m M) ([]K, []V)
- func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
- func MapOrderedKeyValues[M ~map[K]V, K cmp.Ordered, V any](m M) ([]K, []V)
- func MapOrderedKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K
- func MapOrderedValues[M ~map[K]V, K cmp.Ordered, V any](m M) []V
- func MapUnion[M ~map[K]V, K comparable, V any](a, b M) M
- func MapValues[M ~map[K]V, K comparable, V any](m M) []V
- func MarshalProtoJSON(msg proto.Message) ([]byte, error)
- func ParseByteCount(s string) (int64, bool)
- func PrettyBytes(nbytes int64) string
- func ReadFileToLines(filename string) ([]string, error)
- func ReadGCPercent() uint64
- func ReadMemoryLimit() string
- func ReadMetrics(category string) map[string]any
- func ReadToLines(rd io.Reader) ([]string, error)
- func SHA1Sum(data []byte) string
- func SHA256Sum(data []byte) string
- func StartProfiler(addr string)
- func TraceStack(skip int, title string, err interface{}, w io.Writer)
- func UnmarshalProtoJSON(b []byte, m proto.Message) error
- func ZeroOf[T any]() T
- type CSVTable
- type Frame
- type Pair
- type Range
- type Stack
Constants ¶
const ( KiB = 1 << 10 MiB = 1 << 20 GiB = 1 << 30 TiB = 1 << 40 )
Variables ¶
var EssentialProjDirs = []string{"bin", "config", "data", "logs"}
Functions ¶
func CatchPanic ¶ added in v1.0.10
func CatchPanic(title string)
func GetCallStackNames ¶ added in v1.0.10
GetCallStackNames 当前调用栈得名称
func GetEnvInt64 ¶
func GetProjRootDir ¶
func GetProjRootDir() string
func GetProjRootDirOf ¶
func IsFileNotExist ¶
func LoadDotEnv ¶
func MapAdd ¶ added in v1.0.10
func MapAdd[M ~map[K]V, K comparable, V cmp.Ordered](a, b M) M
MapAdd 把b的所有值加到a里
func MapIntersect ¶ added in v1.0.10
func MapIntersect[M ~map[K]V, K, V comparable](a, b M) M
MapIntersect 返回两个map的交集, a ∩ b
func MapKeyValues ¶ added in v1.0.10
func MapKeyValues[M ~map[K]V, K comparable, V any](m M) ([]K, []V)
MapKeyValues 返回map的key和value列表
func MapKeys ¶ added in v1.0.10
func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
MapKeys 返回map的key列表
func MapOrderedKeyValues ¶ added in v1.0.10
MapOrderedKeyValues 返回map里已排序的key和value列表
func MapOrderedKeys ¶ added in v1.0.10
MapOrderedKeys 返回map里已排序的key列表
func MapOrderedValues ¶ added in v1.0.10
MapOrderedValues 返回map里按key排序的value列表
func MapUnion ¶ added in v1.0.10
func MapUnion[M ~map[K]V, K comparable, V any](a, b M) M
MapUnion 返回两个map的并集, copy of a ∪ b
func MapValues ¶ added in v1.0.10
func MapValues[M ~map[K]V, K comparable, V any](m M) []V
MapValues 返回map的value列表
func MarshalProtoJSON ¶ added in v1.0.10
MarshalProtoJSON 序列化proto消息为json格式
func ParseByteCount ¶
ParseByteCount parses a string that represents a count of bytes. suffixes include B, KiB, MiB, GiB, and TiB represent quantities of bytes as defined by the IEC 80000-13 standard
func ReadFileToLines ¶
ReadFileToLines 把文件内容按一行一行读取
func ReadGCPercent ¶ added in v1.0.10
func ReadGCPercent() uint64
ReadGCPercent see https://pkg.go.dev/runtime/debug#SetGCPercent
func ReadMemoryLimit ¶ added in v1.0.10
func ReadMemoryLimit() string
ReadMemoryLimit see https://pkg.go.dev/runtime/debug#SetMemoryLimit
func ReadMetrics ¶ added in v1.0.10
ReadMetrics 读取指定的metrics see https://pkg.go.dev/runtime/metrics
func StartProfiler ¶ added in v1.0.10
func StartProfiler(addr string)
func TraceStack ¶ added in v1.0.10
Types ¶
type CSVTable ¶ added in v1.0.10
CSVTable represents a CSV table
func NewCSVRecords ¶ added in v1.0.10
func NewCSVRecords() *CSVTable
func ReadCSVTable ¶ added in v1.0.10
ReadCSVTable 从csv文件读取数据
func (*CSVTable) GetRowField ¶ added in v1.0.10
GetRowField returns the field value of the column
type Frame ¶ added in v1.0.10
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
type Pair ¶ added in v1.0.10
type Pair[T1, T2 any] struct { First T1 Second T2 }
Pair is a type that provides a way to store two heterogeneous objects as a single unit.
type Range ¶ added in v1.0.10
Range contains a min value and a max value
func ParseRange ¶ added in v1.0.10
type Stack ¶ added in v1.0.10
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a stack of program counters.
func (Stack) CallerNames ¶ added in v1.0.10
CallerNames 获取堆栈函数名