Documentation ¶
Index ¶
- Constants
- func IsHexNumber(b byte) bool
- func IsLowerLetter(b byte) bool
- func IsNumber(b byte) bool
- func IsOctalNumber(b byte) bool
- func IsUpperLetter(b byte) bool
- func IsWhitespace(b byte) bool
- func MergeStrings(outStrings []string) string
- func SearchTest(sr *SliceReader, targetIndex int64, maxLen int64, pattern string) int64
- func StringTest(sr *SliceReader, targetIndex int64, patternString string, ...) int64
- func ToLower(b byte) byte
- func ToUpper(b byte) byte
- type ByteView
- type SliceReader
- func (sr *SliceReader) AbsoluteOffset() int64
- func (sr *SliceReader) AbsoluteSize() int64
- func (sr *SliceReader) Cap(size int64) *SliceReader
- func (sr *SliceReader) ReadAt(buf []byte, index int64) (int, error)
- func (sr *SliceReader) Size() int64
- func (sr *SliceReader) Slice(offset int64) *SliceReader
- type StringFinder
- type StringTestFlags
Constants ¶
const ( // CompactWhitespace ("W" flag) compacts whitespace in the target, // which must contain at least one whitespace character CompactWhitespace = 1 << iota // OptionalBlanks ("w" flag) treats every blank in the magic as an optional blank OptionalBlanks // LowerMatchesBoth ("c" flag) specifies case-insensitive matching: lower case // characters in the magic match both lower and upper case characters // in the target LowerMatchesBoth // UpperMatchesBoth ("C" flag) specifies case-insensitive matching: upper case // characters in the magic match both lower and upper case characters // in the target UpperMatchesBoth // ForceText ("t" flag) forces the test to be done for text files ForceText // ForceBinary ("b" flag) forces the test to be done for binary files ForceBinary )
Variables ¶
This section is empty.
Functions ¶
func IsWhitespace ¶
IsWhitespace tests if a byte is either a space or a tab
func MergeStrings ¶
MergeStrings concatenates a set of strings return by Identify into a string that file(1) would print. For example, it handles \b.
func SearchTest ¶
func SearchTest(sr *SliceReader, targetIndex int64, maxLen int64, pattern string) int64
SearchTest looks for a fixed pattern at any position within a certain length
func StringTest ¶
func StringTest(sr *SliceReader, targetIndex int64, patternString string, flags StringTestFlags) int64
StringTest looks for a string pattern in target, at given index
Types ¶
type ByteView ¶
type ByteView struct { Input *SliceReader LookBack int64 // contains filtered or unexported fields }
ByteView allows treating an io.ReaderAt as a byte array.
type SliceReader ¶
type SliceReader struct {
// contains filtered or unexported fields
}
func NewSliceReader ¶
func NewSliceReader(reader io.ReaderAt, offset int64, size int64) *SliceReader
func (*SliceReader) AbsoluteOffset ¶
func (sr *SliceReader) AbsoluteOffset() int64
func (*SliceReader) AbsoluteSize ¶
func (sr *SliceReader) AbsoluteSize() int64
func (*SliceReader) Cap ¶
func (sr *SliceReader) Cap(size int64) *SliceReader
func (*SliceReader) Size ¶
func (sr *SliceReader) Size() int64
func (*SliceReader) Slice ¶
func (sr *SliceReader) Slice(offset int64) *SliceReader
type StringFinder ¶
type StringFinder struct {
// contains filtered or unexported fields
}
StringFinder efficiently finds strings in a source text. It's implemented using the Boyer-Moore string search algorithm: http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm http://www.cs.utexas.edu/~moore/publications/fstrpos.pdf (note: this aged document uses 1-based indexing)
func MakeStringFinder ¶
func MakeStringFinder(pattern string) *StringFinder
MakeStringFinder prepares a finder for a given pattern
type StringTestFlags ¶
type StringTestFlags int64
StringTestFlags describes how to perform a string test