diff --git a/chunks/chunks.go b/chunks/chunks.go index fa2bf3b4e..9c80767ff 100644 --- a/chunks/chunks.go +++ b/chunks/chunks.go @@ -133,7 +133,7 @@ func (w *Writer) finalizeTail() error { return err } // As the file was pre-allocated, we truncate any superfluous zero bytes. - off, err := tf.Seek(0, os.SEEK_CUR) + off, err := tf.Seek(0, io.SeekCurrent) if err != nil { return err } diff --git a/wal.go b/wal.go index 72e8bc070..3f1cf7d45 100644 --- a/wal.go +++ b/wal.go @@ -290,7 +290,7 @@ func (w *SegmentWAL) truncate(err error, file int, lastOffset int64) error { w.files = w.files[:file+1] // Seek the current file to the last valid offset where we continue writing from. - _, err = w.files[file].Seek(lastOffset, os.SEEK_SET) + _, err = w.files[file].Seek(lastOffset, io.SeekStart) return err } @@ -393,7 +393,7 @@ func (w *SegmentWAL) Truncate(mint int64, keep func(uint64) bool) error { return errors.Wrap(r.Err(), "read candidate WAL files") } - off, err := csf.Seek(0, os.SEEK_CUR) + off, err := csf.Seek(0, io.SeekCurrent) if err != nil { return err } @@ -583,7 +583,7 @@ func (w *SegmentWAL) cut() error { // in the new segment. go func() { w.actorc <- func() error { - off, err := hf.Seek(0, os.SEEK_CUR) + off, err := hf.Seek(0, io.SeekCurrent) if err != nil { return errors.Wrapf(err, "finish old segment %s", hf.Name()) } @@ -1024,7 +1024,7 @@ func (r *walReader) next() bool { // Remember the offset after the last correctly read entry. If the next one // is corrupted, this is where we can safely truncate. - r.lastOffset, r.err = cf.Seek(0, os.SEEK_CUR) + r.lastOffset, r.err = cf.Seek(0, io.SeekCurrent) if r.err != nil { return false } diff --git a/wal_test.go b/wal_test.go index c6552eb62..6d559f5d9 100644 --- a/wal_test.go +++ b/wal_test.go @@ -15,6 +15,7 @@ package tsdb import ( "encoding/binary" + "io" "io/ioutil" "math/rand" "os" @@ -305,7 +306,7 @@ func TestWALRestoreCorrupted(t *testing.T) { testutil.Ok(t, err) defer f.Close() - off, err := f.Seek(0, os.SEEK_END) + off, err := f.Seek(0, io.SeekEnd) testutil.Ok(t, err) testutil.Ok(t, f.Truncate(off-1)) @@ -318,7 +319,7 @@ func TestWALRestoreCorrupted(t *testing.T) { testutil.Ok(t, err) defer f.Close() - off, err := f.Seek(0, os.SEEK_END) + off, err := f.Seek(0, io.SeekEnd) testutil.Ok(t, err) testutil.Ok(t, f.Truncate(off-8)) @@ -331,7 +332,7 @@ func TestWALRestoreCorrupted(t *testing.T) { testutil.Ok(t, err) defer f.Close() - off, err := f.Seek(0, os.SEEK_END) + off, err := f.Seek(0, io.SeekEnd) testutil.Ok(t, err) // Write junk before checksum starts. @@ -346,7 +347,7 @@ func TestWALRestoreCorrupted(t *testing.T) { testutil.Ok(t, err) defer f.Close() - off, err := f.Seek(0, os.SEEK_END) + off, err := f.Seek(0, io.SeekEnd) testutil.Ok(t, err) // Write junk into checksum