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: remove refs to deprecated io/ioutil #350

Merged
merged 1 commit into from
Jul 31, 2023
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
3 changes: 1 addition & 2 deletions examples/kitchensink/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -735,7 +734,7 @@ func (app *KitchenSink) handleHeavyContent(messageID string, callback func(*os.F
}

func (app *KitchenSink) saveContent(content io.ReadCloser) (*os.File, error) {
file, err := ioutil.TempFile(app.downloadDir, "")
file, err := os.CreateTemp(app.downloadDir, "")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions linebot/account_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package linebot

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestIssueLinkToken(t *testing.T) {
if r.URL.Path != endpoint {
t.Errorf("URLPath %s; want %s", r.URL.Path, endpoint)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions linebot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/textproto"
Expand Down Expand Up @@ -292,7 +291,7 @@

func closeResponse(res *http.Response) error {
defer res.Body.Close()
_, err := io.Copy(ioutil.Discard, res.Body)
_, err := io.Copy(io.Discard, res.Body)

Check failure on line 294 in linebot/client.go

View workflow job for this annotation

GitHub Actions / build (1.13)

undefined: io.Discard

Check failure on line 294 in linebot/client.go

View workflow job for this annotation

GitHub Actions / build (1.14)

undefined: io.Discard

Check failure on line 294 in linebot/client.go

View workflow job for this annotation

GitHub Actions / build (1.15)

undefined: io.Discard
return err
}

Expand Down
4 changes: 2 additions & 2 deletions linebot/delivery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package linebot

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestGetNumberMessages(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
_, err := ioutil.ReadAll(r.Body)
_, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions linebot/get_bot_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package linebot

import (
"context"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestGetBotInfo(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions linebot/get_content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestGetMessageContent(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestGetMessageContent(t *testing.T) {
if !reflect.DeepEqual(res, tc.Want.Response) {
t.Errorf("Response %v; want %v", res, tc.Want.Response)
}
bodyGot, err := ioutil.ReadAll(body)
bodyGot, err := io.ReadAll(body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -194,6 +194,6 @@ func BenchmarkGetMessageContent(b *testing.B) {
for i := 0; i < b.N; i++ {
res, _ := client.GetMessageContent("325708A").Do()
defer res.Content.Close()
ioutil.ReadAll(res.Content)
io.ReadAll(res.Content)
}
}
6 changes: 3 additions & 3 deletions linebot/get_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestGetGroupMemberCount(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestGetRoomMemberCount(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions linebot/get_follower_ids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestGetFollowerIDs(t *testing.T) {
if start, want := q.Get("start"), tc.Want.ContinuationToken; start != want {
t.Errorf("ContinuationToken: %s; want %s", start, want)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions linebot/get_ids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestGetGroupMemberIDs(t *testing.T) {
if start, want := q.Get("start"), tc.Want.ContinuationToken; start != want {
t.Errorf("ContinuationToken: %s; want %s", start, want)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func TestGetRoomMemberIDs(t *testing.T) {
if start, want := q.Get("start"), tc.Want.ContinuationToken; start != want {
t.Errorf("ContinuationToken: %s; want %s", start, want)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions linebot/get_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestGetProfile(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestGetGroupMemberProfile(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestGetRoomMemberProfile(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions linebot/get_quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package linebot

import (
"context"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestGetMessageQuota(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestGetMessageQuotaConsumption(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestGetMessageConsumption(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions linebot/get_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestGetGroupSummary(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions linebot/insight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestGetNumberMessagesDelivery(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestGetNumberFollowers(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -442,7 +442,7 @@ func TestGetFriendDemographics(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestGetUserInteractionStats(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions linebot/leave_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package linebot
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestLeaveGroup(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestLeaveRoom(t *testing.T) {
if r.URL.Path != tc.Want.URLPath {
t.Errorf("URLPath %s; want %s", r.URL.Path, tc.Want.URLPath)
}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading
Loading