Fix io.Seek* deprecation errors

This commit is contained in:
Bjørn Erik Pedersen 2023-03-06 10:18:15 +01:00
parent 1edd01aa5f
commit 501e8d313c
3 changed files with 4 additions and 3 deletions

View File

@ -15,6 +15,7 @@ package afero
import (
"fmt"
"io"
"log"
"os"
"path/filepath"
@ -237,7 +238,7 @@ func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, erro
file = mem.NewReadOnlyFileHandle(file.(*mem.File).Data())
}
if flag&os.O_APPEND > 0 {
_, err = file.Seek(0, os.SEEK_END)
_, err = file.Seek(0, io.SeekEnd)
if err != nil {
file.Close()
return nil, err

View File

@ -226,7 +226,7 @@ func TestMultipleOpenFiles(t *testing.T) {
if err != nil {
t.Error("fs.OpenFile failed: " + err.Error())
}
_, err = fh2.Seek(0, os.SEEK_END)
_, err = fh2.Seek(0, io.SeekEnd)
if err != nil {
t.Error(err)
}

View File

@ -47,7 +47,7 @@ func (f *UnionFile) Read(s []byte) (int, error) {
if (err == nil || err == io.EOF) && f.Base != nil {
// advance the file position also in the base file, the next
// call may be a write at this position (or a seek with SEEK_CUR)
if _, seekErr := f.Base.Seek(int64(n), os.SEEK_CUR); seekErr != nil {
if _, seekErr := f.Base.Seek(int64(n), io.SeekCurrent); seekErr != nil {
// only overwrite err in case the seek fails: we need to
// report an eventual io.EOF to the caller
err = seekErr