Skip to content

Commit

Permalink
fix: stop using the deprecated io/ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
web3-bot committed Aug 23, 2023
1 parent 79cd62b commit 0789a85
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cmd/git-remote-ipld/ipld.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"io"
"path"
"strings"

Expand Down Expand Up @@ -82,7 +82,7 @@ func (h *IpnsHandler) ProvideBlock(cid string, tracker *core.Tracker) ([]byte, e
return nil, errors.New("cat error")
}

data, err := ioutil.ReadAll(r)
data, err := io.ReadAll(r)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/git-remote-ipld/ipld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package main
import (
"bytes"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -88,7 +87,7 @@ func setupTest(t *testing.T) string {
t.Fatal("source is not a directory")
}

tmpdir, err := ioutil.TempDir("", "git-test")
tmpdir, err := os.MkdirTemp("", "git-test")
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions core/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
"sync"

"github.com/ipfs/go-cid"
ipfs "github.com/ipfs/go-ipfs-api"
"github.com/ipfs/go-ipld-git"
ipldgit "github.com/ipfs/go-ipld-git"
mh "github.com/multiformats/go-multihash"
"github.com/remeh/sizedwaitgroup"
)
Expand Down Expand Up @@ -154,7 +153,7 @@ func (f *Fetch) processSingle(hash string) error {

/////////////////

err = ioutil.WriteFile(*objectPath, object, 0444)
err = os.WriteFile(*objectPath, object, 0444)
if err != nil {
f.errCh <- fmt.Errorf("fetch: %v", err)
return
Expand Down
4 changes: 2 additions & 2 deletions core/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -124,7 +124,7 @@ func (p *Push) doWork() error {
return fmt.Errorf("push: %v", err)
}

raw, err := ioutil.ReadAll(rawReader)
raw, err := io.ReadAll(rawReader)
if err != nil {
return fmt.Errorf("push: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/dgraph-io/badger"
)

//Tracker tracks which hashes are published in IPLD
// Tracker tracks which hashes are published in IPLD
type Tracker struct {
db *badger.DB

Expand Down
5 changes: 2 additions & 3 deletions util/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"compress/zlib"
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path/filepath"
Expand Down Expand Up @@ -35,11 +34,11 @@ func CompareDirs(srcPath, dstPath string, ignore []string) error {
return a[:len(a)-count]
}

srcEntries, err := ioutil.ReadDir(srcPath)
srcEntries, err := os.ReadDir(srcPath)
if err != nil {
return err
}
dstEntries, err := ioutil.ReadDir(dstPath)
dstEntries, err := os.ReadDir(dstPath)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions util/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package util
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -102,7 +101,7 @@ func CopyDir(src string, dst string) (err error) {
return
}

entries, err := ioutil.ReadDir(src)
entries, err := os.ReadDir(src)
if err != nil {
return
}
Expand Down

0 comments on commit 0789a85

Please sign in to comment.