Skip to content

Commit

Permalink
Merge pull request #302 from mergestat/lint-fixes
Browse files Browse the repository at this point in the history
chore: update some lint issues (deprecated std lib packages)
  • Loading branch information
patrickdevivo authored Oct 1, 2022
2 parents 45beb1a + 61c64e0 commit ec3af79
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"database/sql"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -97,7 +97,7 @@ Example queries can be found in the GitHub repo: https://github.com/mergestat/me
query = args[0]
} else if isPiped(info) {
var stdin []byte
if stdin, err = ioutil.ReadAll(os.Stdin); err != nil {
if stdin, err = io.ReadAll(os.Stdin); err != nil {
handleExitError(fmt.Errorf("failed to read from stdin: %v", err))
}
query = string(stdin)
Expand Down
4 changes: 2 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"

"github.com/mergestat/mergestat-lite/pkg/display"
Expand Down Expand Up @@ -71,7 +71,7 @@ func (h *queryServiceHandler) httpHandler(w http.ResponseWriter, req *http.Reque

var body []byte
var err error
if body, err = ioutil.ReadAll(req.Body); err != nil {
if body, err = io.ReadAll(req.Body); err != nil {
h.handleErr(w, http.StatusBadRequest, err)
return
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/internal/enry/enry_detect_language_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package enry

import (
"io/ioutil"
"os"
"testing"

"github.com/mergestat/mergestat-lite/extensions/internal/tools"
)

func TestEnryDetectLanguage(t *testing.T) {
path := "./testdata/main.go"
fileContents, err := ioutil.ReadFile(path)
fileContents, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/internal/enry/enry_is_binary_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package enry

import (
"io/ioutil"
"os"
"testing"

"github.com/mergestat/mergestat-lite/extensions/internal/tools"
)

func TestEnryIsBinary(t *testing.T) {
path := "./testdata/binary"
fileContents, err := ioutil.ReadFile(path)
fileContents, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/internal/git/native/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package native_test

import (
"fmt"
"io/ioutil"
"os"
"testing"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ func TestSelectKnownContents(t *testing.T) {
}
t.Logf("file: path=%s contents_len=%d", path, len(contents))

expectedFileContents, err := ioutil.ReadFile(fmt.Sprintf("./testdata/%s/%s.testdata", hash, path))
expectedFileContents, err := os.ReadFile(fmt.Sprintf("./testdata/%s/%s.testdata", hash, path))
if err != nil {
t.Fatalf("failed to load fixture file: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/internal/golang/go_mod_to_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package golang

import (
"encoding/json"
"io/ioutil"
"os"
"testing"

"github.com/mergestat/mergestat-lite/extensions/internal/tools"
)

func TestGoModToJSONOK(t *testing.T) {
goMod, err := ioutil.ReadFile("testdata/GoModOK")
goMod, err := os.ReadFile("testdata/GoModOK")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestGoModToJSONEmpty(t *testing.T) {
}

func TestGoModToJSONMissingVals(t *testing.T) {
goMod, err := ioutil.ReadFile("testdata/GoModMissingVals")
goMod, err := os.ReadFile("testdata/GoModMissingVals")
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/internal/npm/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package npm
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"

"github.com/mergestat/mergestat-lite/extensions/options"
Expand Down Expand Up @@ -49,7 +49,7 @@ func (c *Client) GetPackage(ctx context.Context, packageName string) ([]byte, er
return nil, err
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
Expand All @@ -72,7 +72,7 @@ func (c *Client) GetPackageVersion(ctx context.Context, packageName, version str
return nil, err
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/locator/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package locator

import (
"context"
"io/ioutil"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -66,7 +65,7 @@ func determineCloneDir(path, baseCloneDir string) (string, bool, error) {

// if no clone directory is specified, use a tmp dir
if baseCloneDir == "" {
if baseCloneDir, err = ioutil.TempDir(os.TempDir(), "mergestat"); err != nil {
if baseCloneDir, err = os.MkdirTemp("", "mergestat"); err != nil {
return "", false, errors.Wrap(err, "failed to create a temporary directory")
}

Expand Down

0 comments on commit ec3af79

Please sign in to comment.