utils

package
Version: v0.0.0-...-1dc08c0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSingleRune

func GetSingleRune(s string) (rune, error)

GetSingleRune decodes the string s as a single rune if possible.

func RemoveTrailingSpaces

func RemoveTrailingSpaces(input string) string

RemoveTrailingSpaces splits the input string into lines, trims any trailing spaces from each line, then puts the lines back together.

Any newlines at the end of the input string are ignored.

The output string always ends in a newline.

func ToLowerSingleByte

func ToLowerSingleByte(b byte) byte

ToLowerSingleByte returns the lowercase of a given single ASCII byte. A non ASCII byte is returned unchanged.

func TruncateString

func TruncateString(s string, maxRunes int) string

TruncateString truncates a string to a given number of runes.

Types

type EveryN

type EveryN struct {
	// N is the minimum duration of time between log messages.
	N time.Duration

	syncutil.Mutex
	// contains filtered or unexported fields
}

EveryN provides a way to rate limit spammy events. It tracks how recently a given event has occurred so that it can determine whether it's worth handling again.

The zero value for EveryN is usable and is equivalent to Every(0), meaning that all calls to ShouldProcess will return true.

NOTE: If you specifically care about log messages, you should use the version of this in the log package, as it integrates with the verbosity flags.

func Every

func Every(n time.Duration) EveryN

Every is a convenience constructor for an EveryN object that allows a log message every n duration.

func (*EveryN) ShouldProcess

func (e *EveryN) ShouldProcess(now time.Time) bool

ShouldProcess returns whether it's been more than N time since the last event.

type NoCopy

type NoCopy struct{}

NoCopy may be embedded into structs which must not be copied after the first use.

See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.

func (*NoCopy) Lock

func (*NoCopy) Lock()

Lock is a no-op used by -copylocks checker from `go vet`.

func (*NoCopy) Unlock

func (*NoCopy) Unlock()

Unlock is a no-op used by -copylocks checker from `go vet`.

Directories

Path Synopsis
csv
Package csv reads and writes comma-separated values (CSV) files.
Package csv reads and writes comma-separated values (CSV) files.
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
Package interval provides two implementations for an interval tree.
Package interval provides two implementations for an interval tree.
generic
Package generic provides an implementation of a generic immutable interval B-Tree.
Package generic provides an implementation of a generic immutable interval B-Tree.
Package leaktest provides tools to detect leaked goroutines in tests.
Package leaktest provides tools to detect leaked goroutines in tests.
log
Package log implements logging.
Package log implements logging.
Package metric provides server metrics (a.k.a.
Package metric provides server metrics (a.k.a.
aggmetric
Package aggmetric provides functionality to create metrics which expose aggregate metrics for internal collection and additionally per-child reporting to prometheus.
Package aggmetric provides functionality to create metrics which expose aggregate metrics for internal collection and additionally per-child reporting to prometheus.
Package pretty prints documents based on a target line width.
Package pretty prints documents based on a target line width.
singleflight
Package singleflight provides a duplicate function call suppression mechanism.
Package singleflight provides a duplicate function call suppression mechanism.
Package sysutil is a cross-platform compatibility layer on top of package syscall.
Package sysutil is a cross-platform compatibility layer on top of package syscall.
pgdate
Package pgdate contains parsing functions and types for dates and times in a manner that is compatible with PostgreSQL.
Package pgdate contains parsing functions and types for dates and times in a manner that is compatible with PostgreSQL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL