diff --git a/.travis.yml b/.travis.yml index 183f1b7d..0cbcbcb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,9 @@ script: - go test -race -v ./... go: - - 1.5 - - 1.6 - 1.7 - 1.8 + - 1.9 - tip matrix: diff --git a/cmd/gotail/gotail.go b/cmd/gotail/gotail.go index 3da55f23..3c769447 100644 --- a/cmd/gotail/gotail.go +++ b/cmd/gotail/gotail.go @@ -6,6 +6,7 @@ package main import ( "flag" "fmt" + "io" "os" "github.com/hpcloud/tail" @@ -36,7 +37,7 @@ func main() { } if n != 0 { - config.Location = &tail.SeekInfo{-n, os.SEEK_END} + config.Location = &tail.SeekInfo{-n, io.SeekEnd} } done := make(chan bool) diff --git a/tail.go b/tail.go index c99cdaa2..9dd069ff 100644 --- a/tail.go +++ b/tail.go @@ -36,10 +36,10 @@ func NewLine(text string) *Line { return &Line{text, time.Now(), nil} } -// SeekInfo represents arguments to `os.Seek` +// SeekInfo represents arguments to `io.Seek` type SeekInfo struct { Offset int64 - Whence int // os.SEEK_* + Whence int // io.Seek* } type logger interface { @@ -143,7 +143,7 @@ func (tail *Tail) Tell() (offset int64, err error) { if tail.file == nil { return } - offset, err = tail.file.Seek(0, os.SEEK_CUR) + offset, err = tail.file.Seek(0, io.SeekCurrent) if err != nil { return } @@ -336,7 +336,7 @@ func (tail *Tail) tailFileSync() { // reopened if ReOpen is true. Truncated files are always reopened. func (tail *Tail) waitForChanges() error { if tail.changes == nil { - pos, err := tail.file.Seek(0, os.SEEK_CUR) + pos, err := tail.file.Seek(0, io.SeekCurrent) if err != nil { return err } @@ -389,7 +389,7 @@ func (tail *Tail) openReader() { } func (tail *Tail) seekEnd() error { - return tail.seekTo(SeekInfo{Offset: 0, Whence: os.SEEK_END}) + return tail.seekTo(SeekInfo{Offset: 0, Whence: io.SeekEnd}) } func (tail *Tail) seekTo(pos SeekInfo) error { diff --git a/tail_test.go b/tail_test.go index 38d6b84b..975579ab 100644 --- a/tail_test.go +++ b/tail_test.go @@ -8,6 +8,7 @@ package tail import ( _ "fmt" + "io" "io/ioutil" "os" "strings" @@ -178,7 +179,7 @@ func TestLocationFullDontFollow(t *testing.T) { func TestLocationEnd(t *testing.T) { tailTest := NewTailTest("location-end", t) tailTest.CreateFile("test.txt", "hello\nworld\n") - tail := tailTest.StartTail("test.txt", Config{Follow: true, Location: &SeekInfo{0, os.SEEK_END}}) + tail := tailTest.StartTail("test.txt", Config{Follow: true, Location: &SeekInfo{0, io.SeekEnd}}) go tailTest.VerifyTailOutput(tail, []string{"more", "data"}, false) <-time.After(100 * time.Millisecond) @@ -195,7 +196,7 @@ func TestLocationMiddle(t *testing.T) { // Test reading from middle. tailTest := NewTailTest("location-middle", t) tailTest.CreateFile("test.txt", "hello\nworld\n") - tail := tailTest.StartTail("test.txt", Config{Follow: true, Location: &SeekInfo{-6, os.SEEK_END}}) + tail := tailTest.StartTail("test.txt", Config{Follow: true, Location: &SeekInfo{-6, io.SeekEnd}}) go tailTest.VerifyTailOutput(tail, []string{"world", "more", "data"}, false) <-time.After(100 * time.Millisecond) @@ -263,7 +264,7 @@ func TestTell(t *testing.T) { tailTest.CreateFile("test.txt", "hello\nworld\nagain\nmore\n") config := Config{ Follow: false, - Location: &SeekInfo{0, os.SEEK_SET}} + Location: &SeekInfo{0, io.SeekStart}} tail := tailTest.StartTail("test.txt", config) // read noe line <-tail.Lines @@ -276,7 +277,7 @@ func TestTell(t *testing.T) { config = Config{ Follow: false, - Location: &SeekInfo{offset, os.SEEK_SET}} + Location: &SeekInfo{offset, io.SeekStart}} tail = tailTest.StartTail("test.txt", config) for l := range tail.Lines { // it may readed one line in the chan(tail.Lines),