Documentation ¶
Index ¶
- Constants
- func Any2a(v any) string
- func AssertFloat(v any) bool
- func AssertInt(v any) bool
- func AssertNumeric(v any) bool
- func AssertString(v any) bool
- func AssertStringLike(v any) bool
- func AssertUint(v any) bool
- func AssertZero(v any) bool
- func AtoF32(s string) float32
- func AtoF64(s string) float64
- func AtoI64(s string) int64
- func AtoU64(s string) uint64
- func BackgroundContext() context.Context
- func Bytes2StringNoCopy(bs []byte) string
- func BytesGB(bs []byte) float64
- func BytesKB(bs []byte) float64
- func BytesMB(bs []byte) float64
- func BytesOf(bs []byte) string
- func CST2Timestamp(cst string) string
- func Camel2Snake(camelCase string) string
- func CapitalizeFirst(str string) string
- func Colorf(val ...ColorValue)
- func ConRun(fns ...Fn)
- func DeepCopyByJSON(stdJSON JSONLite, v any) any
- func DefaultHTTPClient() *http.Client
- func DoWithBuffer(fn WithBufferFn)
- func ElemIn[E comparable](e E, s ...E) bool
- func ElemsIn[E comparable](src, dst []E) bool
- func F32toa(f32 float32) string
- func F64toa(f64 float64) string
- func GetBuffer() *valyalabuffer.ByteBuffer
- func GetIPv4Str(addr net.Addr) string
- func GetIPv6Str(addr net.Addr) string
- func GetTypeByteSize(varOf any) uintptr
- func GetValueByteSize(varOf any) int
- func GetWorkPath(s ...string) string
- func GoSafe(fn Fn)
- func GreenAny(v any) string
- func GreenF(format string, v ...any) string
- func GzipIOReader2File(ioReader io.Reader, fileName string) (err error)
- func I64toa(i64 int64) string
- func IOGetStr(readCloser io.ReadCloser) string
- func IPFromAddr(addr net.Addr) net.IP
- func IPStringFromAddr(addr []net.Addr) []string
- func IsIPv(ip string) uint8
- func IsIPv4(addr net.Addr) bool
- func IsIPv6(addr net.Addr) bool
- func IsSpace(s string) bool
- func IsURLWithHTTP(url string) bool
- func IsURLWithHTTPS(url string) bool
- func IsURLWithScheme(url string) bool
- func LookupIP(host string) string
- func MapClear[Map ~map[K]V, K comparable, V any](m ...Map)
- func MapCopy[Map ~map[K]V, K comparable, V any](dst, src Map) Map
- func MapDelete[Map ~map[K]V, K comparable, V any](m Map, k ...K)
- func MapElem[Map ~map[K]V, K comparable, V any](m Map, k K) V
- func MapElemOk[Map ~map[K]V, K comparable, V any](m Map, k K) (V, bool)
- func MapEvict[Map1 ~map[K]V1, Map2 ~map[K]V2, K comparable, V1 any, V2 any](dst Map1, src Map2)
- func MapInsert[Map ~map[E]struct{}, E comparable](m Map, e ...E) Map
- func MapKeyMap[Map ~map[K]V, KeyMap ~map[K]struct{}, K comparable, V any](m Map) KeyMap
- func MapKeys[Map ~map[K]V, K comparable, V any](m Map) []K
- func MapMerge[Map ~map[F]M, F comparable, M map[K]V, K comparable, V any](dst, src Map)
- func MapOk[Map ~map[K]V, K comparable, V any](m Map, k K) bool
- func MapValueMap[Map ~map[K]V, ValueMap ~map[V]struct{}, K, V comparable](m Map) ValueMap
- func MapValues[Map ~map[K]V, K comparable, V any](m Map) []V
- func MapsMerge[Map ~map[K]V, K comparable, V any](m ...Map) Map
- func MarshalJSONPretty(v any) (string, error)
- func MeasureByte(size int) string
- func MeasureTime(dur time.Duration) string
- func MergeError(err ...error) error
- func Must(err error)
- func MustDetail(err error)
- func New[T any](val T) *T
- func New2[T any](val T) **T
- func NewBool(bVar bool) *bool
- func NewFloat32(f32 float32) *float32
- func NewFloat64(f64 float64) *float64
- func NewInt32(i32 int32) *int32
- func NewInt64(i64 int64) *int64
- func NewNoZeroInt[T Number](num T) *T
- func NewNoZeroString[T String](s T) *T
- func NewString(str string) *string
- func NewZero[T any](val T) *T
- func NilStruct() struct{}
- func OSCreateAbsoluteDir(dir string) error
- func OSCreateAbsolutePath(filePath string) error
- func OSFilePathExists(filePath string) bool
- func OSOpenFileWithCreate(filePath string) (*os.File, error)
- func OSRemoveFile(filePath string) error
- func PanicHandler(v ...any)
- func Ptr2a(v any) string
- func PutBuffer(bb *valyalabuffer.ByteBuffer)
- func ReadYaml(a any, filePath string) error
- func Recover(fn Fn)
- func RedAny(v any) string
- func RedF(format string, v ...any) string
- func SeqRun(fns ...Fn)
- func SilentCloseIO(msg string, closer io.Closer)
- func SilentError(err error)
- func SilentErrorf(detail string, err error)
- func SilentFatal(err error)
- func SilentFatalf(detail string, err error)
- func SilentPanic(err error)
- func Slice2Map[Slice ~[]E, Map ~map[E]struct{}, E comparable](s Slice) Map
- func Snake2Camel(snakeCase string) string
- func String2BytesNoCopy(s string) []byte
- func String2RuneSlice(s string) []rune
- func StringConcat(s ...string) string
- func StringContainAny(s string, e ...string) bool
- func StringContainsAll(s string, e ...string) bool
- func StringDelete(s string, from ...string) string
- func StringJoin(sep string, s ...string) string
- func StringPrefixIn(s string, p ...string) bool
- func StringQuote(s string) string
- func StringReplaceAlls(s, to string, from ...string) string
- func StringSQuote(s string) string
- func StringSlice2RuneSlice(s []string) []rune
- func TODOContext() context.Context
- func TarIOReader2File(ioReader io.Reader, filePath string) (err error)
- func TestLongHorizontalLine(t *testing.T)
- func TimeSecond(sec int) time.Duration
- func Timestamp2CST(timestamp string) string
- func ToElemPtrMap[ElemMap map[K]E, ElemPtrMap map[K]*E, K comparable, E any](m ElemMap) ElemPtrMap
- func ToElemPtrSlice[ElemSlice []E, ElemPtrSlice []*E, E any](s ElemSlice) ElemPtrSlice
- func TrimNetMask(ip string) string
- func U64toa(u64 uint64) string
- func URLWithHTTP(url string) string
- func URLWithoutHTTP(url string) string
- func YN(v bool) string
- func Zero[V any]() V
- type Byteser
- type ColorValue
- type Fn
- type Func
- type JSONDecoder
- type JSONEncoder
- type JSONLite
- type JSONMarshaler
- type JSONUnmarshaler
- type JSONer
- type Number
- type Page
- func (p *Page) Page() *int64
- func (p *Page) PageIntValue() int
- func (p *Page) PageValue() int64
- func (p *Page) Pair() (*int64, *int64)
- func (p *Page) PairValue() (int64, int64)
- func (p *Page) Size() *int64
- func (p *Page) SizeIntValue() int
- func (p *Page) SizeValue() int64
- func (p *Page) WithOffsetNum(offsetNum int64) *Page
- func (p *Page) WithPageNum(pageNum int64) *Page
- func (p *Page) WithPageSize(pageSize int64) *Page
- type Sizer
- type String
- type Stringer
- type WithBufferFn
Constants ¶
const ( Ki = 1 << 10 Mi = 1 << 20 Gi = 1 << 30 Ti = 1 << 40 Pi = 1 << 50 Ei = 1 << 60 )
<binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei refer from: resource/quantity.go
const ( JSONMarshalPrefix = "" JSONMarshalIndent = " " )
const ( DirMaxPerm = 0755 FileMaxPerm = 0644 )
const ( Tab = "\t" // ASCII 9 Newline = "\n" // ASCII 10 )
space run as string, space character as string
const ( // From Null, following is ASCII 0 ~ 127 Null = `\0` // ASCII 0 Bell = `\a` // ASCII 7 Backspace = `\b` // ASCII 8 HorizontalTab = `\t` // ASCII 9 LineFeed = `\n` // ASCII 10 VerticalTab = `\v` // ASCII 11 FormFeed = `\f` // ASCII 12 CarriageReturn = `\r` // ASCII 13 Escape = `\e` // ASCII 27 Space = ` ` // ASCII 32 ExclamationMark = `!` // ASCII 33 DoubleQuotes = `"` // ASCII 34 SpeechMarks = `"` // ASCII 34 NumberSign = `#` // ASCII 35 Dollar = `$` // ASCII 36 PercentSign = `%` // ASCII 37 Ampersand = `&` // ASCII 38 SingleQuote = `'` // ASCII 39 OpenParenthesis = `(` // ASCII 40 OpenBracket = `(` // ASCII 40 CloseParenthesis = `)` // ASCII 41 CloseBracket = `)` // ASCII 41 Asterisk = `*` // ASCII 42 Plus = `+` // ASCII 43 Comma = `,` // ASCII 44 HyphenMinus = `-` // ASCII 45 Period = `.` // ASCII 46 Dot = `.` // ASCII 46 FullStop = `.` // ASCII 46 Slash = `/` // ASCII 47 Divide = `/` // ASCII 47 Colon = `:` // ASCII 58 Semicolon = `;` // ASCII 59 LessThan = `<` // ASCII 60 OpenAngledBracket = `<` // ASCII 60 Equals = `=` // ASCII 61 GreaterThan = `>` // ASCII 62 CloseAngledBracket = `>` // ASCII 62 QuestionMark = `?` // ASCII 63 AtSign = `@` // ASCII 64 OpeningBracket = `[` // ASCII 91 Backslash = `\` // ASCII 92 ClosingBracket = `]` // ASCII 93 Caret = `^` // ASCII 94 Circumflex = `^` // ASCII 94 Underscore = `_` // ASCII 95 GraveAccent = "`" // ASCII 96 OpeningBrace = `{` // ASCII 123 VerticalBar = `|` // ASCII 124 ClosingBrace = `}` // ASCII 125 EquivalencySign = `~` // ASCII 126 Tilde = `~` // ASCII 126 Delete = `DEL` // ASCII 127 )
Printable and Showable ASCII Table referred from: https://en.wikipedia.org/wiki/ASCII https://www.ascii-code.com/
const ( DurationMinute = time.Second * 60 DurationHour = DurationMinute * 60 DurationHalfDay = DurationHour * 12 DurationDay = DurationHalfDay * 2 DurationWeek = DurationDay * 7 DurationMonth = DurationDay * 30 DurationYear = DurationDay * 365 DurationEra = DurationYear * 10 DurationHalfCentury = DurationEra * 5 DurationCentury = DurationHalfCentury * 2 )
for human read
const (
MagicBufferCap = 16 * Ki
)
const (
MagicMapCap = (iota + 1) << 4
)
const (
MagicSliceCap = (iota + 1) << 3
)
const (
MagicStr = "Ciallo~"
)
const (
TimeLocationAsiaShanghai = "Asia/Shanghai"
)
Variables ¶
This section is empty.
Functions ¶
func AssertFloat ¶ added in v1.2.16
func AssertNumeric ¶ added in v1.2.16
func AssertString ¶ added in v1.2.16
func AssertStringLike ¶ added in v1.2.16
func AssertUint ¶ added in v1.2.16
func AssertZero ¶ added in v1.2.16
func BackgroundContext ¶ added in v1.1.0
func Bytes2StringNoCopy ¶
Bytes2StringNoCopy unsafe, long string panic tested
func CST2Timestamp ¶ added in v1.1.0
CST2Timestamp Convert (CST: UTC+8) to (Unix timestamp)
func Camel2Snake ¶ added in v1.2.7
Camel2Snake +example: snake -> snake +example: snakeToCamel -> snake_to_camel
func CapitalizeFirst ¶ added in v1.2.7
func Colorf ¶ added in v1.2.18
func Colorf(val ...ColorValue)
func DeepCopyByJSON ¶ added in v1.1.9
DeepCopyByJSON tested is ok
func DefaultHTTPClient ¶ added in v1.1.0
func DoWithBuffer ¶ added in v1.2.4
func DoWithBuffer(fn WithBufferFn)
func ElemIn ¶ added in v1.1.8
func ElemIn[E comparable](e E, s ...E) bool
func ElemsIn ¶ added in v1.1.8
func ElemsIn[E comparable](src, dst []E) bool
ElemsIn src all in dst return true ,or not return false
func GetBuffer ¶ added in v1.1.7
func GetBuffer() *valyalabuffer.ByteBuffer
GetBuffer when GetBuffer from ByteBuffer, must call PutBuffer after GetBuffer
func GetIPv4Str ¶ added in v1.1.8
func GetIPv6Str ¶ added in v1.1.8
func GetTypeByteSize ¶ added in v1.1.0
func GetValueByteSize ¶ added in v1.1.0
func GetWorkPath ¶ added in v1.2.15
func GzipIOReader2File ¶ added in v1.1.4
func IOGetStr ¶ added in v1.1.3
func IOGetStr(readCloser io.ReadCloser) string
func IPStringFromAddr ¶ added in v1.1.7
func IsURLWithHTTP ¶ added in v1.1.0
func IsURLWithHTTPS ¶ added in v1.1.0
func IsURLWithScheme ¶ added in v1.1.0
func LookupIP ¶ added in v1.1.7
LookupIP
+example 192.168.31.254 -> 192.168.31.254 +example app.local -> 192.168.31.254 +example 192.168.31.254:80 -> 192.168.31.254:80 +example app.local:80 -> 192.168.31.254:80
func MapClear ¶ added in v1.2.9
func MapClear[Map ~map[K]V, K comparable, V any](m ...Map)
func MapCopy ¶ added in v1.2.9
func MapCopy[Map ~map[K]V, K comparable, V any](dst, src Map) Map
func MapDelete ¶ added in v1.2.9
func MapDelete[Map ~map[K]V, K comparable, V any](m Map, k ...K)
func MapElem ¶ added in v1.2.9
func MapElem[Map ~map[K]V, K comparable, V any](m Map, k K) V
MapElem get elem by k from m, never failure if m == nil
func MapElemOk ¶ added in v1.2.9
func MapElemOk[Map ~map[K]V, K comparable, V any](m Map, k K) (V, bool)
MapElemOk mapaccess2
func MapEvict ¶ added in v1.2.1
func MapEvict[Map1 ~map[K]V1, Map2 ~map[K]V2, K comparable, V1 any, V2 any](dst Map1, src Map2)
MapEvict evict different elem_type map with same key_type map with same key
func MapInsert ¶ added in v1.2.9
func MapInsert[Map ~map[E]struct{}, E comparable](m Map, e ...E) Map
func MapKeyMap ¶ added in v1.2.14
func MapKeyMap[Map ~map[K]V, KeyMap ~map[K]struct{}, K comparable, V any](m Map) KeyMap
func MapKeys ¶ added in v1.2.9
func MapKeys[Map ~map[K]V, K comparable, V any](m Map) []K
func MapMerge ¶ added in v1.2.1
func MapMerge[Map ~map[F]M, F comparable, M map[K]V, K comparable, V any](dst, src Map)
MapMerge merge field in src `M`as elem copy to field in dst `M`as elem
func MapOk ¶ added in v1.1.4
func MapOk[Map ~map[K]V, K comparable, V any](m Map, k K) bool
MapOk check if k in m, never failure if m == nil
func MapValueMap ¶ added in v1.2.14
func MapValueMap[Map ~map[K]V, ValueMap ~map[V]struct{}, K, V comparable](m Map) ValueMap
func MapValues ¶ added in v1.2.9
func MapValues[Map ~map[K]V, K comparable, V any](m Map) []V
func MapsMerge ¶ added in v1.2.15
func MapsMerge[Map ~map[K]V, K comparable, V any](m ...Map) Map
func MarshalJSONPretty ¶ added in v1.1.0
func MeasureByte ¶ added in v1.1.7
func MeasureTime ¶ added in v1.1.7
func MergeError ¶ added in v1.2.4
func MustDetail ¶ added in v1.2.18
func MustDetail(err error)
func NewFloat32 ¶
func NewFloat64 ¶
func NewNoZeroInt ¶ added in v1.2.18
func NewNoZeroInt[T Number](num T) *T
func NewNoZeroString ¶ added in v1.2.18
func NewNoZeroString[T String](s T) *T
func OSCreateAbsoluteDir ¶ added in v1.1.0
func OSCreateAbsolutePath ¶ added in v1.1.0
OSCreateAbsolutePath unix /opt/xxx windows A:\ A:\\ B:\ B:\\ C:\ C:\\ D:\ D:\\
func OSFilePathExists ¶ added in v1.1.0
func OSOpenFileWithCreate ¶ added in v1.1.0
func OSRemoveFile ¶ added in v1.1.0
func PanicHandler ¶ added in v1.2.17
func PanicHandler(v ...any)
func PutBuffer ¶ added in v1.1.7
func PutBuffer(bb *valyalabuffer.ByteBuffer)
PutBuffer return memory to BufferPool
func SilentCloseIO ¶ added in v1.1.7
SilentCloseIO handle io closer error
func SilentError ¶ added in v1.1.7
func SilentError(err error)
SilentError only used in dev env or test env, _test file not to use in production env
func SilentErrorf ¶ added in v1.1.7
SilentErrorf only used in dev env or test env, _test file not to use in production env
func SilentFatal ¶ added in v1.1.7
func SilentFatal(err error)
SilentFatal only used in dev env or test env, _test file not to use in production env
func SilentFatalf ¶ added in v1.1.7
SilentFatalf only used in dev env or test env, _test file not to use in production env
func SilentPanic ¶ added in v1.1.7
func SilentPanic(err error)
SilentPanic only used in dev env or test env, _test file not to use in production env
func Slice2Map ¶ added in v1.2.9
func Slice2Map[Slice ~[]E, Map ~map[E]struct{}, E comparable](s Slice) Map
func Snake2Camel ¶ added in v1.2.7
Snake2Camel +example: snake -> snake +example: snake_to_camel -> snakeToCamel
func String2BytesNoCopy ¶
String2BytesNoCopy unsafe, long string panic tested
func String2RuneSlice ¶ added in v1.2.15
func StringConcat ¶
func StringContainAny ¶ added in v1.2.15
func StringContainsAll ¶ added in v1.2.15
func StringDelete ¶ added in v1.1.9
func StringJoin ¶ added in v1.1.0
func StringPrefixIn ¶ added in v1.1.8
func StringQuote ¶ added in v1.1.8
func StringReplaceAlls ¶ added in v1.1.0
func StringSQuote ¶ added in v1.1.8
func StringSlice2RuneSlice ¶ added in v1.2.15
a bit of wrong for type:rune or type:byte?
func TODOContext ¶ added in v1.1.0
func TarIOReader2File ¶ added in v1.1.4
func TestLongHorizontalLine ¶ added in v1.1.9
func TimeSecond ¶ added in v1.1.7
func Timestamp2CST ¶ added in v1.1.0
Timestamp2CST Convert (Unix timestamp) to (CST: UTC+8)
func ToElemPtrMap ¶ added in v1.2.10
func ToElemPtrMap[ElemMap map[K]E, ElemPtrMap map[K]*E, K comparable, E any](m ElemMap) ElemPtrMap
func ToElemPtrSlice ¶ added in v1.2.10
func ToElemPtrSlice[ElemSlice []E, ElemPtrSlice []*E, E any](s ElemSlice) ElemPtrSlice
func TrimNetMask ¶ added in v1.1.7
func URLWithHTTP ¶
func URLWithoutHTTP ¶ added in v1.1.0
Types ¶
type ColorValue ¶ added in v1.2.18
type JSONDecoder ¶ added in v1.1.9
type JSONEncoder ¶ added in v1.1.0
type JSONLite ¶ added in v1.2.15
type JSONLite interface { JSONMarshaler JSONUnmarshaler }
type JSONMarshaler ¶ added in v1.2.15
type JSONUnmarshaler ¶ added in v1.2.15
type JSONer ¶ added in v1.1.9
type JSONer interface { JSONMarshaler JSONUnmarshaler JSONEncoder JSONDecoder }
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func NewPageConfig ¶
func (*Page) PageIntValue ¶ added in v1.1.0
func (*Page) SizeIntValue ¶ added in v1.1.0
func (*Page) WithOffsetNum ¶
func (*Page) WithPageNum ¶
func (*Page) WithPageSize ¶
type WithBufferFn ¶ added in v1.2.4
type WithBufferFn func(buf *valyalabuffer.ByteBuffer)
Source Files ¶
- align.go
- archive_tar.go
- assert.go
- binary_size.go
- bufferpool.go
- color.go
- compress_gzip.go
- context.go
- dev_tool.go
- error.go
- filepath.go
- func.go
- generic.go
- io.go
- json.go
- map.go
- net.go
- net_http.go
- os.go
- page.go
- ptr.go
- slice.go
- str_rune.go
- strconv.go
- string.go
- string_copy_go120.go
- struct.go
- test.go
- time.go
- yaml.go