common

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2String added in v0.0.4

func Bytes2String(b []byte) string

func If

func If[T any](condition bool, trueVal, falseVal T) T

伪三元表达式 PS: 请注意,由于go的机制, trueVal, falseVal 都是已定值(在传入if前就确定了), 可能会导致panic

func Recover

func Recover(msg string, goAfterRecover func(err error))

Recover 恢复panic 仅限于在 go routine 中,放置在第一行执行 严禁在主线程使用

func SplitBy added in v0.0.4

func SplitBy(content, spliter, escape string) (ret []string)

使用分隔符与转义符对字符串进行分割 $content 字符串内容 $spliter 分隔符 $escape 转义符

func SplitHead added in v0.0.8

func SplitHead(content, spliter, escape string) (ret [2]string)

使用分隔符与转义符对字符串进行分割(只拆分出第一个) $content 字符串内容 $spliter 分隔符 $escape 转义符

func String2Bytes added in v0.0.4

func String2Bytes(s string) []byte

func Try

func Try(invoke func())

Try 保护方法运行

func TryCatch

func TryCatch(invoke func(), fallback func(err error))

TryCatch 保护方法运行,如果失败,则执行fallback方法

Types

type NoCopy added in v0.0.10

type NoCopy struct{}

func (*NoCopy) Lock added in v0.0.10

func (*NoCopy) Lock()

func (*NoCopy) Unlock added in v0.0.10

func (*NoCopy) Unlock()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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