Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated os.SEEK consts #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ script:
- go test -race -v ./...

go:
- 1.5
- 1.6
- 1.7
- 1.8
- 1.9
- tip

matrix:
Expand Down
3 changes: 2 additions & 1 deletion cmd/gotail/gotail.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"flag"
"fmt"
"io"
"os"

"github.com/hpcloud/tail"
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions tail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package tail

import (
_ "fmt"
"io"
"io/ioutil"
"os"
"strings"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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),
Expand Down