Skip to content

Commit

Permalink
Fix lint errors for using deprecated functionality (#35)
Browse files Browse the repository at this point in the history
Functionality from `io/ioutil` has moved to the `io` and `os` packages
in go1.16 ([reference](https://pkg.go.dev/io/ioutil)).

Confirmed that staticcheck passes when run with:

```
staticcheck -checks SA1019 ./...
```
  • Loading branch information
pietern authored Sep 7, 2022
1 parent 31a841f commit c00db56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/sync/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
Expand All @@ -28,7 +28,7 @@ func githubGetPAT(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
raw, err := ioutil.ReadAll(response.Body)
raw, err := io.ReadAll(response.Body)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -58,7 +58,7 @@ func githubGetPAT(ctx context.Context) (string, error) {
if err != nil {
return retries.Halt(err)
}
raw, err := ioutil.ReadAll(response.Body)
raw, err := io.ReadAll(response.Body)
if err != nil {
return retries.Continuef("failed to read body: %w", err)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func githubGetPAT(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
raw, _ = ioutil.ReadAll(response.Body)
raw, _ = io.ReadAll(response.Body)
log.Printf("[INFO] %s", raw)
// TODO: convert to PAT
return bearer, nil
Expand Down
3 changes: 1 addition & 2 deletions git/fileset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package git
import (
"fmt"
"io/fs"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -45,7 +44,7 @@ func MustGetFileSet() FileSet {

func New(root string) FileSet {
lines := []string{".git"}
rawIgnore, err := ioutil.ReadFile(fmt.Sprintf("%s/.gitignore", root))
rawIgnore, err := os.ReadFile(fmt.Sprintf("%s/.gitignore", root))
if err == nil {
// add entries from .gitignore if the file exists (did read correctly)
for _, line := range strings.Split(string(rawIgnore), "\n") {
Expand Down
4 changes: 2 additions & 2 deletions project/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package project

import (
"fmt"
"io/ioutil"
"io"
"os"
"reflect"

Expand Down Expand Up @@ -83,7 +83,7 @@ func loadProjectConf() (prj Project, err error) {
if err != nil {
return
}
raw, err := ioutil.ReadAll(config)
raw, err := io.ReadAll(config)
if err != nil {
return
}
Expand Down

0 comments on commit c00db56

Please sign in to comment.