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

remove ioutil #74

Merged
merged 2 commits into from
Mar 28, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.15.x', '1.16.x' ]
go: [ '1.16.x' ]
steps:

- name: Set up Go
Expand Down
3 changes: 1 addition & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/signal"
"runtime"
Expand Down Expand Up @@ -243,7 +242,7 @@ func (c *CLI) uploadSnippet(ctx context.Context, filename, uploadFilename, filet
}
defer reader.Close()

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

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -67,7 +66,7 @@ func (c *Config) LoadEnv() error {
}

func (c *Config) LoadTOML(filename string) error {
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
if err != nil {
return err
}
Expand Down
9 changes: 4 additions & 5 deletions slack/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"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -55,7 +54,7 @@ func NewClient(urlStr string, logger *log.Logger) (*Client, error) {
return nil, fmt.Errorf("failed to parse url: %s: %w", urlStr, err)
}

var discardLogger = log.New(ioutil.Discard, "", log.LstdFlags)
var discardLogger = log.New(io.Discard, "", log.LstdFlags)
if logger == nil {
logger = discardLogger
}
Expand All @@ -70,7 +69,7 @@ func NewClient(urlStr string, logger *log.Logger) (*Client, error) {
}

func NewClientForPostFile(logger *log.Logger) (*Client, error) {
var discardLogger = log.New(ioutil.Discard, "", log.LstdFlags)
var discardLogger = log.New(io.Discard, "", log.LstdFlags)
if logger == nil {
logger = discardLogger
}
Expand Down Expand Up @@ -116,7 +115,7 @@ func (c *Client) PostText(ctx context.Context, param *PostTextParam) error {
}

if res.StatusCode != http.StatusOK {
b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read res.Body and the status code of the response from slack was not 200: %w", err)
}
Expand Down Expand Up @@ -163,7 +162,7 @@ func (c *Client) PostFile(ctx context.Context, token string, param *PostFilePara
return err
}

b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions slack/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package slack_test
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestPostText_Success(t *testing.T) {
t.Fatalf("Content-Type expected %s, but %s", expectedType, contentType)
}

bodyBytes, err := ioutil.ReadAll(r.Body)
bodyBytes, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestPostFile_Success(t *testing.T) {
t.Fatalf("Content-Type expected %s, but %s", expectedType, contentType)
}

bodyBytes, err := ioutil.ReadAll(r.Body)
bodyBytes, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestPostFile_Success_provideFiletype(t *testing.T) {
t.Fatalf("Content-Type expected %s, but %s", expectedType, contentType)
}

bodyBytes, err := ioutil.ReadAll(r.Body)
bodyBytes, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down