Documentation
¶
Overview ¶
Package byteutil implements functions for the manipulation of byte slices.
Index ¶
- func AppendDecimal(b []byte, v int64, pow int) []byte
- func AppendSize(b []byte, v uint64, size ByteSize) []byte
- func Btoi(b []byte) int64
- func Btou(b []byte) uint64
- func Btox(b []byte) uint64
- func Column(b []byte) (col, rest []byte)
- func ColumnString(b []byte) (col string, rest []byte)
- func Columns(b []byte, dst ...*[]byte) (n int, rest []byte)
- func Equal(a, b []byte) bool
- func Field(b []byte) (key, val []byte)
- func ToLower(b []byte) []byte
- func ToTitle(b []byte) []byte
- func ToTitleString(s string) string
- func TrimByte(b []byte, c byte) []byte
- func WriteDecimal(w io.Writer, v int64, pow int) (n int, err error)
- func WriteSize(w io.Writer, v uint64, size ByteSize) (n int, err error)
- type ByteRate
- type ByteSize
- type MultiFileReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendDecimal ¶
AppendDecimal appends the string format of the fixed-point number v, with pow places after the deciaml point, to b and returns the extended buffer. The value appended will be padded with 0's to reach the desired decimal places pow.
func AppendSize ¶
AppendSize appends the string representation of v bytes scaled to size, with 3 decimal places of precision.
func Btoi ¶
Btou is a naive base 10 implementation of strconv.ParseInt that assumes all the bytes of b are numerical characters, and ignores any that aren't.
func Btou ¶
Btou is a naive base 10 implementation of strconv.ParseUint that assumes all the bytes of b are numerical characters, and ignores any that aren't.
func Btox ¶
Btou is a naive base 16 implementation of strconv.ParseUint that assumes all the bytes of b are numerical characters, and ignores any that aren't.
func Column ¶
Column splits b by the first space and returns the subslice of b before the space and the remainder of b after the space with spaces trimmed.
func ColumnString ¶
ColumnString is the same as Column but returns the subslice before the space as a string
func Columns ¶
Columns splits b into len(dst) columns using Column and returns the number columns parsed and the remainder of b.
func Field ¶
Field splits b by the first ':' and returns the subslice of b before the colon with spaces trimmed and the subslice of b after the colon.
func ToLower ¶
ToLower is equivalent to bytes.ToLower but modifies b in place instead of making a copy.
func ToTitleString ¶
ToTitleString returns the title case representation of s.
func TrimByte ¶
TrimByte returns the subslice of b with all leading and trailing occurences of c sliced off.
func WriteDecimal ¶
WriteDecimal writes the output of AppendDecimal to w.
Types ¶
type ByteRate ¶
type ByteRate int
A ByteSize is the human-readable representation of a byte count.
Binary prefix human-readable rates.
func (ByteRate) MarshalJSON ¶
MarshalJSON marshals r into the double-quoted string representation.
type ByteSize ¶
type ByteSize int
A ByteSize is the human-readable representation of a byte count.
const UnknownSize ByteSize = -1
func (ByteSize) MarshalJSON ¶
MarshalJSON marshals s into the double-quoted string representation.
type MultiFileReader ¶
type MultiFileReader struct {
// contains filtered or unexported fields
}
MultiFileReader implements the io.Reader and io.Closer interfaces by reading the contents of multiple files.
func NewMultiFileReader ¶
func NewMultiFileReader(name ...string) *MultiFileReader
NewMultiFileReader returns a new MultiFileReader that reads from the given files.
func (*MultiFileReader) Close ¶
func (r *MultiFileReader) Close() (err error)
Close implements the io.Closer interface. It closes the currently open file.
func (*MultiFileReader) Read ¶
func (r *MultiFileReader) Read(p []byte) (n int, err error)
Read implements the io.Reader interface. Once the end of a file is read the next call to Read will open the next file. Any errors encountered while opening a file will be returned, and io.EOF is returned once all the files have reached EOF.