Exemplo n.º 1
0
// Text returns the CharType of the first 4096 bytes of the Buffer.
func (b *Buffer) Text() characterize.CharType {
	if b.texted {
		return b.text
	}
	b.texted = true
	buf, err := b.Slice(0, readSz)
	if err == nil || err == io.EOF {
		b.text = characterize.Detect(buf)
	}
	return b.text
}
Exemplo n.º 2
0
func (m *Matcher) Identify(na string, buf siegreader.Buffer) (chan core.Result, error) {
	if *m > 0 {
		tt := characterize.Detect(siegreader.ReaderFrom(buf))
		if tt != characterize.DATA {
			res := make(chan core.Result, *m)
			for i := 1; i < int(*m)+1; i++ {
				res <- result{
					idx:   i,
					basis: "text match " + tt.String(),
				}
			}
			close(res)
			return res, nil
		}
	}
	res := make(chan core.Result)
	close(res)
	return res, nil
}