Documentation
¶
Index ¶
- func ConstantTimeStringEquals(x, y string) bool
- func DropRunes(s string, n int) string
- func GenSecureRandomId(n int) string
- func IsAsciiWord(s string) bool
- func IsAsciiWordWithDigits(s string) bool
- func MaskAll(s string) string
- func Masked(k string, v string) zap.Field
- func RemoveStrFromSliceInPlace(slice []string, target string) []string
- func TakeRunes(s string, n int) string
- func TrimAllInPlace(slice []string) []string
- type ConstError
- type SizedBufferPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeStringEquals ¶
Returns true iff the two string, x and y, have equal contents. Time depends on the length of the string. If length are different, then returns immediately.
func GenSecureRandomId ¶
func IsAsciiWord ¶
func IsAsciiWordWithDigits ¶
func RemoveStrFromSliceInPlace ¶
Remove occupancies of the given string from the slice. Mutates original array.
Types ¶
type ConstError ¶
type ConstError string
func (ConstError) Error ¶
func (e ConstError) Error() string
type SizedBufferPool ¶
type SizedBufferPool struct {
// contains filtered or unexported fields
}
SizedBufferPool implements a pool of bytes.Buffers in the form of a bounded channel. Buffers are pre-allocated to the requested size.
func NewSizedBufferPool ¶
func NewSizedBufferPool(size int, alloc int) (bp *SizedBufferPool)
SizedBufferPool creates a new BufferPool bounded to the given size. size defines the number of buffers to be retained in the pool and alloc sets the initial capacity of new buffers to minimize calls to make().
The value of alloc should seek to provide a buffer that is representative of most data written to the the buffer (i.e. 95th percentile) without being overly large (which will increase static memory consumption). You may wish to track the capacity of your last N buffers (i.e. using an []int) prior to returning them to the pool as input into calculating a suitable alloc value.
func (*SizedBufferPool) WithBuffer ¶
func (bp *SizedBufferPool) WithBuffer(f func(b *bytes.Buffer))
Run the given function providing a buffer from the pool. The buffer will be returned to the pool when function f has finished its job.