Skip to content

Commit

Permalink
Fix io.Seek* deprecation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 6, 2023
1 parent 5a707ee commit 748fa44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion memmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package afero

import (
"fmt"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -232,7 +233,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
Expand Down
2 changes: 1 addition & 1 deletion memmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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)
}
Expand Down
2 changes: 1 addition & 1 deletion unionFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 748fa44

Please sign in to comment.