Browse Source

fix megacheck issues: os.SEEK_SET is deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.

pull/5805/head
Mario Trangoni 7 years ago
parent
commit
c0e888e82b
  1. 2
      chunks/chunks.go
  2. 8
      wal.go
  3. 9
      wal_test.go

2
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
}

8
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
}

9
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

Loading…
Cancel
Save