utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeParseLayout      = "2006-01-02 15:04:05"
	FilePrefixTimeLayout = "2006-01-02_150405"
)

Variables

View Source
var TimeLoc, _ = time.LoadLocation("Asia/Shanghai")

Functions

func Bcs

func Bcs(b []byte) string

Bcs converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice header will change in the future go versions.

func BtoA

func BtoA(b *byte) (s string)

BtoA converts a byte to string without memory allocation.

func GenerateId

func GenerateId(origin uint64) string

func Scb

func Scb(s string) (b []byte)

Scb converts string to a byte slice without memory allocation.

Note it may break if string and/or slice header will change in the future go versions.

func TimeCmp

func TimeCmp(t1 time.Time, t2 time.Time) (cmp int, d time.Duration)

TimeCmp TimeCmp(t1,t2) d=abs(t1-t2) t1==t2 TimeCmp(t1,t2)==0 t1>t2 TimeCmp(t1,t2)>0 t1>t2 TimeCmp(t1,t2)<0

Types

type ChanMap

type ChanMap[K comparable, V any] struct {
	Del chan K
	// contains filtered or unexported fields
}

func NewChMap

func NewChMap[K comparable, V any](cap int) (ChanMap[K, V], map[K]V)

func (ChanMap[K, V]) Cap

func (cMap ChanMap[K, V]) Cap() int

func (ChanMap[K, V]) Put

func (cMap ChanMap[K, V]) Put(key K, val V) (ok bool)

Jump to

Keyboard shortcuts

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