helper

package
v18.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxCommitOrTagMessageSize = 10 * 1024

MaxCommitOrTagMessageSize is the threshold for a commit/tag message, if exceeded then message is truncated and it's up to the client to request it in full separately.

Functions

func ByteSliceHasAnyPrefix

func ByteSliceHasAnyPrefix(s []byte, prefixes ...string) bool

ByteSliceHasAnyPrefix tests whether the byte slice s begins with any of the prefixes.

func IsNumber

func IsNumber(s []byte) bool

IsNumber tests whether the byte slice s contains only digits or not

func SanitizeError

func SanitizeError(err error) error

SanitizeError does the same thing as SanitizeString but for error types

func SanitizeString

func SanitizeString(str string) string

SanitizeString will clean password and tokens from URLs, and replace them with [FILTERED].

func UnquoteBytes

func UnquoteBytes(s []byte) []byte

UnquoteBytes removes surrounding double-quotes from a byte slice returning a new slice if they exist, otherwise it returns the same byte slice passed.

Types

type CountingWriter

type CountingWriter struct {
	W io.Writer
	N int64
}

CountingWriter wraps an io.Writer and counts all the writes. Accessing the count N is not thread-safe.

func (*CountingWriter) Write

func (cw *CountingWriter) Write(p []byte) (int, error)

type ManualTicker

type ManualTicker struct {
	StopFunc  func()
	ResetFunc func()
	// contains filtered or unexported fields
}

ManualTicker implements a ticker that ticks when Tick is called. Stop and Reset functions call the provided functions.

func NewCountTicker

func NewCountTicker(n int, callback func()) *ManualTicker

NewCountTicker returns a ManualTicker with a ResetFunc that calls the provided callback on Reset call after it has been called N times.

func NewManualTicker

func NewManualTicker() *ManualTicker

NewManualTicker returns a Ticker that can be manually controlled.

func (*ManualTicker) C

func (mt *ManualTicker) C() <-chan time.Time

func (*ManualTicker) Reset

func (mt *ManualTicker) Reset()

func (*ManualTicker) Stop

func (mt *ManualTicker) Stop()

func (*ManualTicker) Tick

func (mt *ManualTicker) Tick()

type Ticker

type Ticker interface {
	C() <-chan time.Time
	Stop()
	Reset()
}

Ticker ticks on the channel returned by C to signal something.

func NewTimerTicker

func NewTimerTicker(interval time.Duration) Ticker

NewTimerTicker returns a Ticker that ticks after the specified interval has passed since the previous Reset call.

type TickerFactory

type TickerFactory interface {
	// NewTicker returns a new Ticker.
	NewTicker() Ticker
}

TickerFactory constructs a new ticker.

func NewNullTickerFactory

func NewNullTickerFactory() TickerFactory

NewNullTickerFactory returns new tickers that don't tick.

func NewTimerTickerFactory

func NewTimerTickerFactory(interval time.Duration) TickerFactory

NewTimerTickerFactory returns new tickers that tick after the given interval.

type TickerFactoryFunc

type TickerFactoryFunc func() Ticker

TickerFactoryFunc is a function that implements TickerFactory

func (TickerFactoryFunc) NewTicker

func (fn TickerFactoryFunc) NewTicker() Ticker

NewTicker returns a new ticker.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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