Skip to content

Commit

Permalink
Stop using ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Feb 19, 2023
1 parent 448011d commit d9e2011
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif

.PHONY: lint
lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.43.0 golangci-lint run -c .golangci.yaml
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.51.1 golangci-lint run -c .golangci.yaml

.PHONY: tests
tests:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ rows:
Dashboard creation (or [automatically as a Kubernetes Resource, using DARK](https://github.com/K-Phoen/dark)):
```go
content, err := ioutil.ReadFile("dashboard.yaml")
content, err := os.ReadFile("dashboard.yaml")
if err != nil {
fmt.Fprintf(os.Stderr, "Could not read file: %s\n", err)
os.Exit(1)
Expand Down
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
)

Expand Down Expand Up @@ -61,7 +60,7 @@ func (client *Client) modifyRequest(request *http.Request) {
}

func (client Client) httpError(resp *http.Response) error {
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions dashboards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ package grabana
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/K-Phoen/sdk"
"github.com/stretchr/testify/require"

"github.com/K-Phoen/grabana/alert"

"github.com/K-Phoen/grabana/dashboard"
"github.com/K-Phoen/grabana/row"
"github.com/K-Phoen/grabana/text"
"github.com/K-Phoen/grabana/timeseries"
"github.com/stretchr/testify/require"
)

func TestADashboardCanBeFoundByTitle(t *testing.T) {
Expand Down Expand Up @@ -842,7 +841,7 @@ func TestDashboardsCanBeCreatedWithNewAlertsAndDeletesPreviousAlerts(t *testing.
// new alert creation
if r.Method == http.MethodPost && r.URL.String() == "/api/ruler/grafana/api/v1/rules/Folder%20name" {
newAlertCreated = true
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
req.NoError(err)

req.JSONEq(`{
Expand Down
3 changes: 1 addition & 2 deletions doc/unmarshalling_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"

"github.com/K-Phoen/grabana/decoder"
Expand All @@ -20,7 +19,7 @@ import (
func main() {
filePath := "some/awesome/dashboard.yaml"

content, err := ioutil.ReadFile(filePath)
content, err := os.ReadFile(filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not read file: %s\n", err)
os.Exit(1)
Expand Down

0 comments on commit d9e2011

Please sign in to comment.