Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: replace io/ioutil with io and os package #997

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package main

import (
"errors"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestLintReports(t *testing.T) {
allFiles := make(map[string]string)
var reports []string
for _, dir := range []string{reportsDir, excludedDir} {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil && !errors.Is(err, os.ErrNotExist) {
t.Fatalf("unable to read %v/: %s", dir, err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -76,7 +75,7 @@ func main() {

flag.Parse()
if *githubTokenFile != "" {
data, err := ioutil.ReadFile(*githubTokenFile)
data, err := os.ReadFile(*githubTokenFile)
if err != nil {
die("%v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/database/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -97,7 +96,7 @@ func generateEntries(ctx context.Context, repoDir string) (map[string][]osv.Entr
return nil, nil, err
}

yamlFiles, err := ioutil.ReadDir(filepath.Join(repoDir, yamlDir))
yamlFiles, err := os.ReadDir(filepath.Join(repoDir, yamlDir))
if err != nil {
return nil, nil, fmt.Errorf("can't read %q: %s", yamlDir, err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/database/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package database
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -46,7 +46,7 @@ func loadDB(dbPath string) (_ client.DBIndex, _ map[string][]osv.Entry, err erro

var loadDir func(string) error
loadDir = func(path string) error {
dir, err := ioutil.ReadDir(path)
dir, err := os.ReadDir(path)
if err != nil {
return err
}
Expand All @@ -58,7 +58,7 @@ func loadDB(dbPath string) (_ client.DBIndex, _ map[string][]osv.Entry, err erro
}
continue
}
content, err := ioutil.ReadFile(fpath)
content, err := os.ReadFile(fpath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/issues/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package issues
import (
"context"
"flag"
"io/ioutil"
"os"
"strings"
"testing"

Expand All @@ -37,7 +37,7 @@ func TestClient(t *testing.T) {
if *githubTokenFile == "" {
t.Fatal("need -ghtokenfile")
}
data, err := ioutil.ReadFile(*githubTokenFile)
data, err := os.ReadFile(*githubTokenFile)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/worker/gen_false_positives.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"context"
"fmt"
"go/format"
"io/ioutil"
"log"
"os"
"strings"
Expand Down Expand Up @@ -288,7 +287,7 @@ func run(repoPath string) error {
if err != nil {
return err
}
return ioutil.WriteFile("false_positive_records.gen.go", src, 0644)
return os.WriteFile("false_positive_records.gen.go", src, 0644)
}

func buildCVERecords(repo *git.Repository) ([]*store.CVERecord, error) {
Expand Down