Documentation ¶
Index ¶
- Variables
- func ByteHexString(b byte) string
- func Decode(k, d []byte) string
- func FastRand() uint32
- func FastRandN(n int) uint32
- type Builder
- func (b *Builder) Cap() int
- func (b *Builder) Grow(n int)
- func (b *Builder) InsertByte(c byte) error
- func (b *Builder) Len() int
- func (b *Builder) Output() string
- func (b *Builder) Reset()
- func (b *Builder) String() string
- func (b *Builder) Write(p []byte) (int, error)
- func (b *Builder) WriteByte(c byte) error
- func (b *Builder) WriteString(s string) (int, error)
Constants ¶
This section is empty.
Variables ¶
var Rand = getRandom()
Rand is the custom Random number generator, based on the current time as a seed. This struct is overridden by the tag "stdrand". By default, it will use the "unsafe" fastrand() implentation which is faster, but contains less entropy than the built-in, 'rand.Rand', which requires more memory and binary storage space.
Functions ¶
func ByteHexString ¶ added in v0.1.0
ByteHexString is a simple function that will quickly lookup a byte value to it's associated hex value.
func Decode ¶
Decode is used to un-encode a string written in a XOR byte array "encrypted" by the specified key. This function returns the string value of the result but also modifies the input array, which can be used to re-use the resulting string.
func FastRand ¶
func FastRand() uint32
FastRand is a fast thread local random function. This should be used in place instead of 'Rand.Uint32()'.
Taken from https://github.com/dgraph-io/ristretto/blob/master/z/rtutil.go Thanks!
Types ¶
type Builder ¶ added in v0.1.0
type Builder struct {
// contains filtered or unexported fields
}
A Builder is used to efficiently build a string using Write methods. It minimizes memory copying. The zero value is ready to use. Do not copy a non-zero Builder.
Re-implemented to remove UTF8 dependency and added some useful functions.
func (*Builder) Cap ¶ added in v0.1.0
Cap returns the capacity of the builder's underlying byte slice. It is the total space allocated for the string being built and includes any bytes already written.
func (*Builder) Grow ¶ added in v0.1.0
Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow is a NOP.
func (*Builder) InsertByte ¶ added in v0.1.0
InsertByte appends the byte c to b's buffer at the zero position. The returned error is always nil.
func (*Builder) Len ¶ added in v0.1.0
Len returns the number of accumulated bytes; b.Len() == len(b.String()).
func (*Builder) Output ¶ added in v0.1.0
Output returns the accumulated string, then resets the value of this Builder.
func (*Builder) Reset ¶ added in v0.1.0
func (b *Builder) Reset()
Reset resets the Builder to be empty.
func (*Builder) Write ¶ added in v0.1.0
Write appends the contents of p to b's buffer. Write always returns len(p), nil.