Remove usage of deprecated ioutil package

This commit is contained in:
adisbladis 2022-09-02 15:47:48 +12:00
parent b57059cef6
commit fc2d392494
2 changed files with 6 additions and 8 deletions

View file

@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
@ -21,7 +20,7 @@ func main() {
pkgs := make(map[string]*Package)
{
b, err := ioutil.ReadFile(os.Getenv("sourcesPath"))
b, err := os.ReadFile(os.Getenv("sourcesPath"))
if err != nil {
panic(err)
}
@ -33,7 +32,7 @@ func main() {
}
{
b, err := ioutil.ReadFile(os.Getenv("jsonPath"))
b, err := os.ReadFile(os.Getenv("jsonPath"))
if err != nil {
panic(err)
}
@ -65,7 +64,7 @@ func main() {
}
if _, err := os.Stat(filepath.Join("vendor", path)); err == nil {
files, err := ioutil.ReadDir(src)
files, err := os.ReadDir(src)
if err != nil {
panic(err)
}
@ -76,7 +75,7 @@ func main() {
if err := os.Symlink(innerSrc, dst); err != nil {
// assume it's an existing directory, try to link the directory content instead.
// TODO should we do this recursively
files, err := ioutil.ReadDir(innerSrc)
files, err := os.ReadDir(innerSrc)
if err != nil {
panic(err)
}

View file

@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -16,9 +15,9 @@ import (
"sync"
"github.com/nix-community/go-nix/pkg/nar"
log "github.com/sirupsen/logrus"
"github.com/nix-community/gomod2nix/internal/lib"
schema "github.com/nix-community/gomod2nix/internal/schema"
log "github.com/sirupsen/logrus"
"golang.org/x/mod/modfile"
)
@ -45,7 +44,7 @@ func common(directory string) ([]*goModDownload, map[string]string, error) {
}).Info("Parsing go.mod")
// Read go.mod
data, err := ioutil.ReadFile(goModPath)
data, err := os.ReadFile(goModPath)
if err != nil {
return nil, nil, err
}