util

package
v0.0.0-...-8d64414 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesHash64

func BytesHash64(b []byte) int64

BytesHash64 returns the fnv hash of a bytes

func Fatal

func Fatal(args ...interface{})

Fatal prints the message and exits the program.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf prints the message and exits the program.

func Hash64

func Hash64(n int64) int64

Hash64 returns a fnv Hash of the integer.

func RandBytes

func RandBytes(r *rand.Rand, b []byte)

RandBytes fills the bytes with alphabetic characters randomly

func Slice

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

Slice converts string to slice without copy. Use at your own risk.

func String

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

String converts slice to string without copy. Use at your own risk.

func StringHash64

func StringHash64(s string) int64

StringHash64 returns the fnv hash of a string

Types

type BufPool

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

BufPool is a bytes.Buffer pool

func NewBufPool

func NewBufPool() *BufPool

NewBufPool creates a buffer pool.

func (*BufPool) Get

func (b *BufPool) Get() *bytes.Buffer

Get gets a buffer.

func (*BufPool) Put

func (b *BufPool) Put(buf *bytes.Buffer)

Put returns a buffer.

type SpinLock

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

SpinLock implements a simple atomic spin lock, the zero value for a SpinLock is an unlocked spinlock.

func (*SpinLock) Lock

func (sl *SpinLock) Lock()

Lock locks sl. If the lock is already in use, the caller blocks until Unlock is called

func (*SpinLock) String

func (sl *SpinLock) String() string

func (*SpinLock) TryLock

func (sl *SpinLock) TryLock() bool

TryLock will try to lock sl and return whether it succeed or not without blocking.

func (*SpinLock) Unlock

func (sl *SpinLock) Unlock()

Unlock unlocks sl, unlike [Mutex.Unlock](http://golang.org/pkg/sync/#Mutex.Unlock), there's no harm calling it on an unlocked SpinLock

Jump to

Keyboard shortcuts

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