Documentation ¶
Index ¶
- Variables
- func CompareSemVer(lhs, rhs string) (int, error)
- func DistinctStrings(arrays ...[]string) []string
- func Execute(args ...string) (exitCode int, output []byte, err error)
- func HumanReadableBytesDecimal(bytes int64, sigdig int) string
- func HumanReadableBytesSI(bytes int64, sigdig int) string
- func LaterDate(t1, t2 time.Time) time.Time
- func LatestDate(dates ...time.Time) time.Time
- func NewTimeUUID() uuid.UUID
- func StringToArgs(in string) []string
- func TimeUUID(t time.Time) uuid.UUID
- type BufferPool
- type Repeater
- type Sentinel
- type SentinelChannel
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSemVer = errors.New("invalid semver format")
ErrInvalidSemVer indicates a semver value that is not correctly formatted.
var Nothing = Sentinel{}
Nothing represents an empty value, used for values in set-type maps.
Functions ¶
func CompareSemVer ¶
CompareSemVer compares two SemVer values, and returns -1 if lhs is less (older) than rhs, 1 if lhs is greater (newer) than rhs, and 0 if they are equivalent. The error will be ErrInvalidSemVer if either value is not valid semver format, or nil otherwise.
func DistinctStrings ¶
DistinctStrings returns the array of unique values among the given string arrays.
func Execute ¶
Execute a check and return its exit code. Based on http://stackoverflow.com/a/10385867/7426 and http://nathanleclaire.com/blog/2014/12/29/shelled-out-commands-in-golang/.
func HumanReadableBytesDecimal ¶
HumanReadableBytesDecimal returns decimal-style human-readable byte count representation.
func HumanReadableBytesSI ¶
HumanReadableBytesSI returns SI-style human-readable byte count representation.
func LatestDate ¶
LatestDate returns the latest of the given dates.
func NewTimeUUID ¶
func NewTimeUUID() uuid.UUID
NewTimeUUID generates a UUID-style 16-byte identifier, with the first 8 bytes being the current time in nanoseconds since the Unix epoch, and the last 8 bytes being randomly set, ensuring that the RFC4122 variant bit is not set. These can be sorted and compared lexically as if they were a timestamp, but remain resilient against collisions and do not expose MAC addess or other host information.
func StringToArgs ¶
StringToArgs converts a shell-style string into an argv-style array.
Types ¶
type BufferPool ¶
BufferPool maintains a pool of reusable byte buffers.
func NewBufferPool ¶
func NewBufferPool(initialSize, maxSize, poolSize int) *BufferPool
NewBufferPool constructs a new buffer pool and initializes half the pool.
func (*BufferPool) Get ¶
func (p *BufferPool) Get() *bytes.Buffer
Get a buffer from the pool. Consumers should Give() the buffer back after use.
func (*BufferPool) Give ¶
func (p *BufferPool) Give(b *bytes.Buffer)
Give a buffer back to the pool. Consumers should not use the buffer after calling Give.
type Repeater ¶
type Repeater struct { Interval time.Duration C SentinelChannel // contains filtered or unexported fields }
Repeater repeats calls to a channel, allowing for changes in repeat interval while running without disturbing cadence.
func StartRepeater ¶
StartRepeater starts a new repeater with the given interval. The first call to the channel will be after interval.
func (*Repeater) Stop ¶
func (r *Repeater) Stop()
Stop the repeater and close the channel. The Repeater cannot be reused.
func (*Repeater) UpdateInterval ¶
UpdateInterval updates the interval this Repeater repeats at. The next call to the channel will be newInterval from the last time it fired.
type SentinelChannel ¶
type SentinelChannel chan Sentinel
SentinelChannel is a low-overhead signalling channel.
func (SentinelChannel) Signal ¶
func (sc SentinelChannel) Signal()
Signal sends an object over the channel.