go fmt and line nr tweak
This commit is contained in:
parent
f9d3068eb9
commit
bad984954b
26
scanner.go
26
scanner.go
|
@ -1,4 +1,5 @@
|
|||
package dns
|
||||
|
||||
// Implement a simple scanner, return a byte stream from an io reader.
|
||||
|
||||
import (
|
||||
|
@ -8,26 +9,27 @@ import (
|
|||
)
|
||||
|
||||
type scan struct {
|
||||
src *bufio.Reader
|
||||
position scanner.Position
|
||||
src *bufio.Reader
|
||||
position scanner.Position
|
||||
}
|
||||
|
||||
func scanInit(r io.Reader) *scan {
|
||||
s := new(scan)
|
||||
s.src = bufio.NewReader(r)
|
||||
s.position.Line = 1
|
||||
return s
|
||||
}
|
||||
|
||||
// tokenText returns the next byte from the input
|
||||
func (s *scan) tokenText() (byte, error) {
|
||||
c, err := s.src.ReadByte()
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
if c == '\n' {
|
||||
s.position.Line++
|
||||
s.position.Column = 0
|
||||
}
|
||||
s.position.Column++
|
||||
return c, nil
|
||||
c, err := s.src.ReadByte()
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
if c == '\n' {
|
||||
s.position.Line++
|
||||
s.position.Column = 0
|
||||
}
|
||||
s.position.Column++
|
||||
return c, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue