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

chore: Update ioutil package to io / os packages. #376

Merged
merged 1 commit into from
Apr 26, 2022
Merged
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
4 changes: 2 additions & 2 deletions api/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package http
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"

"github.com/multiformats/go-multihash"
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *Server) execGQL(w http.ResponseWriter, r *http.Request) {
func (s *Server) loadSchema(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()
var result client.QueryResult
sdl, err := ioutil.ReadAll(r.Body)
sdl, err := io.ReadAll(r.Body)

defer func() {
err = r.Body.Close()
Expand Down
4 changes: 2 additions & 2 deletions cli/defradb/cmd/blocks_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package cmd
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -56,7 +56,7 @@ var getCmd = &cobra.Command{
}
}()

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
if err != nil {
log.ErrorE(ctx, "request failed", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cli/defradb/cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package cmd
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -51,7 +51,7 @@ var dumpCmd = &cobra.Command{
}
}()

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
if err != nil {
log.ErrorE(ctx, "request failed", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cli/defradb/cmd/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package cmd
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -52,7 +52,7 @@ var pingCmd = &cobra.Command{
}
}()

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
if err != nil {
log.ErrorE(ctx, "request failed", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cli/defradb/cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package cmd
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -83,7 +83,7 @@ the additional documentation found at: https://hackmd.io/@source/BksQY6Qfw.
}
}()

buf, err := ioutil.ReadAll(res.Body)
buf, err := io.ReadAll(res.Body)
if err != nil {
log.ErrorE(ctx, "request failed", err)
return
Expand Down
7 changes: 4 additions & 3 deletions cli/defradb/cmd/schema_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
"strings"

"github.com/sourcenetwork/defradb/logging"
Expand All @@ -42,7 +43,7 @@ var addCmd = &cobra.Command{
if len(args) > 0 {
schema = []byte(strings.Join(args, "\n"))
} else if schemaFile != "" {
buf, err := ioutil.ReadFile(schemaFile)
buf, err := os.ReadFile(schemaFile)
cobra.CheckErr(err)
schema = buf
} else {
Expand Down Expand Up @@ -70,7 +71,7 @@ var addCmd = &cobra.Command{
}
}()

result, err := ioutil.ReadAll(res.Body)
result, err := io.ReadAll(res.Body)
cobra.CheckErr(err)
log.Info(ctx, "", logging.NewKV("Result", string(result)))
},
Expand Down
9 changes: 4 additions & 5 deletions db/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"fmt"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -690,7 +689,7 @@ func checkIfDatabaseFormatChangesAreDocumented() bool {
return false
}

func getDatabaseFormatDocumentation(startPath string, allowDescend bool) ([]fs.FileInfo, bool) {
func getDatabaseFormatDocumentation(startPath string, allowDescend bool) ([]fs.DirEntry, bool) {
startInfo, err := os.Stat(startPath)
if err != nil {
panic(err)
Expand All @@ -704,15 +703,15 @@ func getDatabaseFormatDocumentation(startPath string, allowDescend bool) ([]fs.F
}

for {
directoryContents, err := ioutil.ReadDir(currentDirectory)
directoryContents, err := os.ReadDir(currentDirectory)
if err != nil {
panic(err)
}

for _, directoryItem := range directoryContents {
directoryItemPath := path.Join(currentDirectory, directoryItem.Name())
if directoryItem.Name() == documentationDirectoryName {
probableFormatChangeDirectoryContents, err := ioutil.ReadDir(directoryItemPath)
probableFormatChangeDirectoryContents, err := os.ReadDir(directoryItemPath)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -741,7 +740,7 @@ func getDatabaseFormatDocumentation(startPath string, allowDescend bool) ([]fs.F
panic("Database documentation directory not found")
}
} else {
return []fs.FileInfo{}, false
return []fs.DirEntry{}, false
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package node

import (
"context"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -179,14 +178,14 @@ func getHostKey(keypath string) (crypto.PrivKey, error) {
if err := os.MkdirAll(keypath, os.ModePerm); err != nil {
return nil, err
}
if err = ioutil.WriteFile(pth, bytes, 0400); err != nil {
if err = os.WriteFile(pth, bytes, 0400); err != nil {
return nil, err
}
return key, nil
} else if err != nil {
return nil, err
} else {
bytes, err := ioutil.ReadFile(pth)
bytes, err := os.ReadFile(pth)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion tools/configs/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ linters-settings:
# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*
ignore: fmt:.*

# [deprecated] use exclude-functions instead.
# path to a file containing a list of functions to exclude from checking
Expand Down