util

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDigit

func IsDigit(r byte) bool

func Lcm

func Lcm(vals []uint32) uint32

Lcm returns the least common multiple

func Max

func Max(a, b uint32) uint32

func MaxInt

func MaxInt(a, b int) int

func Min

func Min(a, b uint32) uint32

func NaturalLess

func NaturalLess(s, t string) bool

NaturalLess compares strings lexicographically *except* substrings of numbers are sorted numerically

func ParseIngestFromFlags added in v0.13.0

func ParseIngestFromFlags(ingestFromStr string) (map[uint32]int64, error)

func ReadEntry

func ReadEntry(TomlFilename string, EntryName string) interface{}

func TS

func TS(ts interface{}) string

Types

type BufferPool

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

func NewBufferPool

func NewBufferPool() *BufferPool

func (*BufferPool) Get

func (b *BufferPool) Get() []byte

func (*BufferPool) Put

func (b *BufferPool) Put(buf []byte)

type Limiter

type Limiter chan struct{}

Limiter provides a mechanism for limiting concurrency. Users need to call Acquire() before starting work and Release() when the work is done. Acquire() will block if the Limiters limit has already been reached and unblock when another thread calls Release(), or the passed context is canceled.

func NewLimiter

func NewLimiter(l int) Limiter

NewLimiter creates a limiter with l slots

func (Limiter) Acquire

func (l Limiter) Acquire(ctx context.Context) bool

Acquire returns when a slot is available. If the limit is reached it will block until another thread calls Release() or the context is done. In the latter case we return false.

func (Limiter) Release

func (l Limiter) Release()

type NaturalSortStringSlice

type NaturalSortStringSlice []string

NaturalSortStringSlice sorts strings lexicographically *except* substrings of numbers are sorted numerically

func (NaturalSortStringSlice) Len

func (ss NaturalSortStringSlice) Len() int

func (NaturalSortStringSlice) Less

func (ss NaturalSortStringSlice) Less(i, j int) bool

func (NaturalSortStringSlice) Swap

func (ss NaturalSortStringSlice) Swap(i, j int)

type Sum32aStringWriter added in v0.13.0

type Sum32aStringWriter uint32

Sum32aStringWriter is mostly a copy of fnv.sum32a the only difference is the additional method WriteString(), due to this additional method it satisfies the io.StringWriter interface which can prevent unnecessary conversions to/from byte slices

func NewFnv32aStringWriter added in v0.13.0

func NewFnv32aStringWriter() Sum32aStringWriter

func (*Sum32aStringWriter) BlockSize added in v0.13.0

func (s *Sum32aStringWriter) BlockSize() int

func (*Sum32aStringWriter) Reset added in v0.13.0

func (s *Sum32aStringWriter) Reset()

func (*Sum32aStringWriter) Size added in v0.13.0

func (s *Sum32aStringWriter) Size() int

func (*Sum32aStringWriter) Sum added in v0.13.0

func (s *Sum32aStringWriter) Sum(in []byte) []byte

func (*Sum32aStringWriter) Sum32 added in v0.13.0

func (s *Sum32aStringWriter) Sum32() uint32

func (*Sum32aStringWriter) Write added in v0.13.0

func (s *Sum32aStringWriter) Write(data []byte) (int, error)

func (*Sum32aStringWriter) WriteString added in v0.13.0

func (s *Sum32aStringWriter) WriteString(data string) (int, error)

type Sum64aStringWriter added in v0.13.0

type Sum64aStringWriter uint64

Sum64aStringWriter is mostly a copy of fnv.sum64a the only difference is the additional method WriteString(), due to this additional method it satisfies the io.StringWriter interface which can prevent unnecessary conversions to/from byte slices

func NewFnv64aStringWriter added in v0.13.0

func NewFnv64aStringWriter() Sum64aStringWriter

func (*Sum64aStringWriter) BlockSize added in v0.13.0

func (s *Sum64aStringWriter) BlockSize() int

func (*Sum64aStringWriter) Reset added in v0.13.0

func (s *Sum64aStringWriter) Reset()

func (*Sum64aStringWriter) Size added in v0.13.0

func (s *Sum64aStringWriter) Size() int

func (*Sum64aStringWriter) Sum added in v0.13.0

func (s *Sum64aStringWriter) Sum(in []byte) []byte

func (*Sum64aStringWriter) Sum64 added in v0.13.0

func (s *Sum64aStringWriter) Sum64() uint64

func (*Sum64aStringWriter) Write added in v0.13.0

func (s *Sum64aStringWriter) Write(data []byte) (int, error)

func (*Sum64aStringWriter) WriteString added in v0.13.0

func (s *Sum64aStringWriter) WriteString(data string) (int, error)

Jump to

Keyboard shortcuts

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