Documentation ¶
Index ¶
- Variables
- func Copy(source, dest string, flags int, perm os.FileMode) error
- func DebugMsg(header string, msg string, args ...interface{})
- func ErrFormatColored(color FormatColor, msg string, fmtArgs ...interface{})
- func ErrorMsg(header string, msg string, args ...interface{})
- func FormatBold(msg string, fmtArgs ...interface{})
- func FormatColored(color FormatColor, msg string, fmtArgs ...interface{})
- func FormatWrap(out io.Writer, width int, indent int, str string, fmtArgs ...interface{})
- func FormatWrapSpecial(out io.Writer, width int, indent int, firstLineOffset int, str string, ...)
- func HumanSized(num int) string
- func InfoMsg(header string, msg string, args ...interface{})
- func NewColoredStream(file *os.File) io.Writer
- func PadString(str string, desiredLen int) string
- func PadStringL(str string, pad string, length int) string
- func PadStringR(str string, pad string, length int) string
- func ReadByte(inStream io.Reader) (byte, error)
- func ReadInt16BE(inStream io.Reader) (int16, error)
- func ReadInt16LE(inStream io.Reader) (int16, error)
- func ReadInt32BE(inStream io.Reader) (int32, error)
- func ReadInt32LE(inStream io.Reader) (int32, error)
- func ReadInt64LE(inStream io.Reader) (int64, error)
- func ReadNullString(inStream io.Reader, length uint) (string, error)
- func ReadString(inStream io.Reader, length uint) (string, error)
- func ReadTrimString(inStream io.Reader, length uint, keepNulls bool, fromFirstNull bool) (string, error)
- func ReadUint16LE(inStream io.Reader) (uint16, error)
- func ReadUint32LE(inStream io.Reader) (uint32, error)
- func ReadUint64LE(inStream io.Reader) (uint64, error)
- func StreamFormatColored(out io.Writer, color FormatColor, msg string, fmtArgs ...interface{})
- func WarnMsg(header string, msg string, args ...interface{})
- func WrapString(str string, lineWidth int, indentWidth int) string
- func WrapStringSpecial(str string, lineWidth int, indentWidth int, firstLineOffset int) string
- func WriteByte(num byte, outStr io.Writer) error
- func WriteIndent(out io.Writer, width int)
- func WriteInt16LE(num int16, outStr io.Writer) error
- func WriteInt32LE(num int32, outStr io.Writer) error
- func WriteInt64LE(num int64, outStr io.Writer) error
- func WritePadding(length int, outStr io.Writer)
- func WriteUint16LE(num uint16, outStr io.Writer) error
- func WriteUint32LE(num uint32, outStr io.Writer) error
- func WriteUint64LE(num uint64, outStr io.Writer) error
- func YesOrNo(question string, fullResponse bool) bool
- type FormatColor
Constants ¶
This section is empty.
Variables ¶
var ( StdoutColored = colorable.NewColorableStdout() StderrColored = colorable.NewColorableStderr() )
var SizeSuffixes = [9]string{"Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
The suffixes used by HumanSized()
Functions ¶
func Copy ¶
Copies a file from source to dest. Both source and dest are filenames. If an error occurs, that error is returned. Otherwise nil is returned. flags and perm are the same as in os.OpenFile().
func ErrFormatColored ¶
func ErrFormatColored(color FormatColor, msg string, fmtArgs ...interface{})
Formats and prints colored text to the terminal's standard error stream.
func FormatBold ¶
func FormatBold(msg string, fmtArgs ...interface{})
A convenience function that formats and prints bold white text to the terminal's standard output stream. This is equivalent to calling, as an example:
FormatColored(FormatWhiteBold, "My Message\n")
func FormatColored ¶
func FormatColored(color FormatColor, msg string, fmtArgs ...interface{})
Formats and prints colored text to the terminal's standard output stream.
func FormatWrap ¶
Convenience function that formats and prints text to an io.Writer, wrapping the text with WrapString first.
func FormatWrapSpecial ¶
func FormatWrapSpecial(out io.Writer, width int, indent int, firstLineOffset int, str string, fmtArgs ...interface{})
Convenience function that formats and prints text to an io.Writer, wrapping the text with WrapStringSpecial first.
func HumanSized ¶
Takes an integer and returns a string containing its representation as a floating point number, appending one of the strings in SuffixSizes depending on its magnitude. This basically pretty prints a size (for example, 1024 bytes is returned as "1.00 KiB").
func PadString ¶
Takes str and adds desiredLen null bytes to the end of it, then returns the new string.
func PadStringL ¶
Takes str and prepends pad onto it until it is length bytes long, then returns the new string. If appending the padding onto the string makes it longer than length, the result is first truncated so that it is exactly length bytes.
func PadStringR ¶
Takes str and appends pad onto it until it is length bytes long, then returns the new string. If appending the padding onto the string makes it longer than length, the result is first truncated so that it is exactly length bytes.
func ReadByte ¶
Reads a single byte from inStream and returns it and nil. If an error occurs, 0 and that error is returned. If it could not read a byte, 0 and a new error is returned.
func ReadInt16BE ¶
Reads a 16-bit signed big endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadInt16LE ¶
Reads a 16-bit signedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadInt32BE ¶
Reads a 32-bit signed big endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadInt32LE ¶
Reads a 32-bit signedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadInt64LE ¶
Reads a 64-bit signedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadNullString ¶
Reads a null-terminated string of at most length bytes from inStream and returns it and nil. If an error occurs, an empty string and an error is returned.
func ReadString ¶
Reads a string of length bytes from inStream and returns it and nil. If an error occurs, an empty string and an error is returned.
func ReadTrimString ¶
func ReadTrimString(inStream io.Reader, length uint, keepNulls bool, fromFirstNull bool) (string, error)
Reads a string of length bytes from inStream, optinally removing null bytes. If keepNulls is true, no nulls are removed. If fromFirstNull is true, all bytes starting from the first null byte are removed, whether the remaining bytes are null or not.. If an error occurs, an empty string and an error is returned.
func ReadUint16LE ¶
Reads a 16-bit unsignedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadUint32LE ¶
Reads a 32-bit unsignedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func ReadUint64LE ¶
Reads a 64-bit unsignedf little endian integer from inStream and returns it and nil. If an error occurs, 0 and an error is returned.
func StreamFormatColored ¶
func StreamFormatColored(out io.Writer, color FormatColor, msg string, fmtArgs ...interface{})
func WrapString ¶
Reformats str so that none of its lines are longer than lineWidth. indentWidth spaces are also is prepended onto each reformatted line. Returns the newly formatted string.
func WrapStringSpecial ¶
Reformats str so that none of its lines are longer than lineWidth. indentWidth spaces are prepended onto each reformatted line. Additionally, the first line's width is reduced by firstLineOffset before indentation is applied to it. Returns the newly formatted string.
func WriteByte ¶
Writes a single byte to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WriteInt16LE ¶
Writes a 16-bit signed little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WriteInt32LE ¶
Writes a 32-bit signed little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WriteInt64LE ¶
Writes a 64-bit signed little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WritePadding ¶
Writes length null bytes to outStr.
func WriteUint16LE ¶
Writes a 16-bit unsigned little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WriteUint32LE ¶
Writes a 32-bit unsigned little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
func WriteUint64LE ¶
Writes a 64-bit unsigned little-endian integer to outStr. On success, nil is returned. If an error occurs, an error is returned.
Types ¶
type FormatColor ¶
type FormatColor int
const ( FormatRed FormatColor = iota FormatYellow FormatWhite FormatBlue FormatGreen FormatBlack FormatMagenta FormatCyan FormatRedBold FormatYellowBold FormatWhiteBold FormatBlueBold FormatGreenBold FormatMagentaBold FormatCyanBold )