From 602886c6b865baac35a50c6c7afeac8d46b74c5b Mon Sep 17 00:00:00 2001 From: Julien Laffaye Date: Sat, 4 Mar 2017 13:01:41 +0100 Subject: [PATCH] Do not export the scanner type It is an internal specific to parse list responses. --- parse.go | 2 +- scanner.go | 16 ++++++++-------- scanner_test.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/parse.go b/parse.go index 0232b18..076062a 100644 --- a/parse.go +++ b/parse.go @@ -72,7 +72,7 @@ func parseLsListLine(line string) (*Entry, error) { return nil, errUnsupportedListLine } - scanner := NewScanner(line) + scanner := newScanner(line) fields := scanner.NextFields(6) if len(fields) < 6 { diff --git a/scanner.go b/scanner.go index 3b5ffdb..0dcc8ae 100644 --- a/scanner.go +++ b/scanner.go @@ -1,20 +1,20 @@ package ftp -// A Scanner for fields delimited by one or more whitespace characters -type Scanner struct { +// A scanner for fields delimited by one or more whitespace characters +type scanner struct { bytes []byte position int } -// NewScanner creates a new Scanner -func NewScanner(str string) *Scanner { - return &Scanner{ +// newScanner creates a new scanner +func newScanner(str string) *scanner { + return &scanner{ bytes: []byte(str), } } // NextFields returns the next `count` fields -func (s *Scanner) NextFields(count int) []string { +func (s *scanner) NextFields(count int) []string { fields := make([]string, 0, count) for i := 0; i < count; i++ { if field := s.Next(); field != "" { @@ -27,7 +27,7 @@ func (s *Scanner) NextFields(count int) []string { } // Next returns the next field -func (s *Scanner) Next() string { +func (s *scanner) Next() string { sLen := len(s.bytes) // skip trailing whitespace @@ -53,6 +53,6 @@ func (s *Scanner) Next() string { } // Remaining returns the remaining string -func (s *Scanner) Remaining() string { +func (s *scanner) Remaining() string { return string(s.bytes[s.position:len(s.bytes)]) } diff --git a/scanner_test.go b/scanner_test.go index 939f70e..86ff4bf 100644 --- a/scanner_test.go +++ b/scanner_test.go @@ -6,7 +6,7 @@ import "github.com/stretchr/testify/assert" func TestScanner(t *testing.T) { assert := assert.New(t) - s := NewScanner("foo bar x y") + s := newScanner("foo bar x y") assert.Equal("foo", s.Next()) assert.Equal(" bar x y", s.Remaining()) assert.Equal("bar", s.Next()) @@ -21,7 +21,7 @@ func TestScanner(t *testing.T) { func TestScannerEmpty(t *testing.T) { assert := assert.New(t) - s := NewScanner("") + s := newScanner("") assert.Equal("", s.Next()) assert.Equal("", s.Next()) assert.Equal("", s.Remaining())