Skip to content

Commit

Permalink
storage: filesystem, switch from os.SEEK_* to io.Seek* (#421)
Browse files Browse the repository at this point in the history
The `os.SEEK_*` constants have been deprecated since Go 1.7.
It is now recommended to use the equivalent `io.Seek*` constants.

Switch `os.SEEK_CUR` to `io.SeekCurrent`,
and `os.SEEK_SET` to `io.SeekStart`.
  • Loading branch information
abhinav committed Dec 10, 2021
1 parent f438ca3 commit 1a8f803
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions storage/filesystem/dotgit/dotgit_test.go
Expand Up @@ -3,6 +3,7 @@ package dotgit
import (
"bufio"
"encoding/hex"
"io"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -510,13 +511,13 @@ func (s *SuiteDotGit) TestObjectPackWithKeepDescriptors(c *C) {
c.Assert(filepath.Ext(pack.Name()), Equals, ".pack")

// Move to an specific offset
pack.Seek(42, os.SEEK_SET)
pack.Seek(42, io.SeekStart)

pack2, err := dir.ObjectPack(plumbing.NewHash(f.PackfileHash))
c.Assert(err, IsNil)

// If the file is the same the offset should be the same
offset, err := pack2.Seek(0, os.SEEK_CUR)
offset, err := pack2.Seek(0, io.SeekCurrent)
c.Assert(err, IsNil)
c.Assert(offset, Equals, int64(42))

Expand All @@ -527,7 +528,7 @@ func (s *SuiteDotGit) TestObjectPackWithKeepDescriptors(c *C) {
c.Assert(err, IsNil)

// If the file is opened again its offset should be 0
offset, err = pack2.Seek(0, os.SEEK_CUR)
offset, err = pack2.Seek(0, io.SeekCurrent)
c.Assert(err, IsNil)
c.Assert(offset, Equals, int64(0))

Expand Down
4 changes: 2 additions & 2 deletions storage/filesystem/object_test.go
Expand Up @@ -71,15 +71,15 @@ func (s *FsSuite) TestGetFromPackfileKeepDescriptors(c *C) {
pack1, err := dg.ObjectPack(packfiles[0])
c.Assert(err, IsNil)

pack1.Seek(42, os.SEEK_SET)
pack1.Seek(42, io.SeekStart)

err = o.Close()
c.Assert(err, IsNil)

pack2, err := dg.ObjectPack(packfiles[0])
c.Assert(err, IsNil)

offset, err := pack2.Seek(0, os.SEEK_CUR)
offset, err := pack2.Seek(0, io.SeekCurrent)
c.Assert(err, IsNil)
c.Assert(offset, Equals, int64(0))

Expand Down

0 comments on commit 1a8f803

Please sign in to comment.