util

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 58

Documentation

Index

Constants

View Source
const (
	TimeFormat         = "2006-01-02 15:04:05"
	DateFormat         = "2006-01-02"
	UnixTimeUnitOffset = uint64(time.Millisecond / time.Nanosecond)
)

Variables

This section is empty.

Functions

func AddPathSeparatorIfAbsent

func AddPathSeparatorIfAbsent(path string) string

func CreateDirIfNotExists

func CreateDirIfNotExists(dirname string) error

func CurrentTimeMillis

func CurrentTimeMillis() uint64

Returns the current Unix timestamp in milliseconds.

func CurrentTimeMillsWithTicker added in v0.4.0

func CurrentTimeMillsWithTicker() uint64

func CurrentTimeNano

func CurrentTimeNano() uint64

Returns the current Unix timestamp in nanoseconds.

func DecrementAndGetInt64 added in v0.4.0

func DecrementAndGetInt64(v *int64) int64

func FileExists

func FileExists(name string) (b bool, err error)

func FilePosition

func FilePosition(file *os.File) (int64, error)

func Float64Equals added in v0.6.0

func Float64Equals(x, y float64) bool

func FormatDate

func FormatDate(tsMillis uint64) string

FormatDate formats Unix timestamp (ms) to date string

func FormatTimeMillis

func FormatTimeMillis(tsMillis uint64) string

FormatTimeMillis formats Unix timestamp (ms) to time string.

func IncrementAndGetInt64

func IncrementAndGetInt64(v *int64) int64

func IsBlank

func IsBlank(s string) bool

IsBlank checks whether the given string is blank.

func NewUuid added in v0.3.0

func NewUuid() string

func RunWithRecover

func RunWithRecover(f func())

func StartTimeTicker added in v0.4.0

func StartTimeTicker()

StartTimeTicker starts a background task that caches current timestamp per millisecond, which may provide better performance in high-concurrency scenarios.

Types

type AtomicBool

type AtomicBool struct {
	// contains filtered or unexported fields
}

func (*AtomicBool) CompareAndSet

func (b *AtomicBool) CompareAndSet(old, new bool) bool

func (*AtomicBool) Get

func (b *AtomicBool) Get() bool

func (*AtomicBool) Set

func (b *AtomicBool) Set(value bool)

type SliceHeader

type SliceHeader struct {
	Data unsafe.Pointer
	Len  int
	Cap  int
}

SliceHeader is a safe version of SliceHeader used within this project.

type StringHeader

type StringHeader struct {
	Data unsafe.Pointer
	Len  int
}

StringHeader is a safe version of StringHeader used within this project.

Jump to

Keyboard shortcuts

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