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

Fix/golangci lint 1.61 warnings: Fix SA1019: "io/ioutil" has been deprecated since Go 1.19 in favour of "io" #92

Merged
merged 2 commits into from
Sep 24, 2024
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: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ jobs:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v4.1.7
- uses: golangci/golangci-lint-action@v6.0.1
with:
version: v1.61.0
- run: make test
15 changes: 7 additions & 8 deletions decoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"mime/quotedprintable"
Expand Down Expand Up @@ -47,7 +46,7 @@ func decodeContent(
cte ContentTransferEncoding,
) (io.Reader, error) {
var contentReader io.Reader
contentBytes, err := ioutil.ReadAll(content)
contentBytes, err := io.ReadAll(content)
if err != nil && err != io.ErrUnexpectedEOF {
return nil, fmt.Errorf(
"letters.decoders.decodeContent: cannot decode content: %w",
Expand All @@ -57,10 +56,10 @@ func decodeContent(
switch cte {
case cteBase64:
decoded := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(contentBytes))
b, err := ioutil.ReadAll(decoded)
b, err := io.ReadAll(decoded)
if err == io.ErrUnexpectedEOF {
decoded = base64.NewDecoder(base64.RawStdEncoding, bytes.NewReader(contentBytes))
b, err = ioutil.ReadAll(decoded)
b, err = io.ReadAll(decoded)
if err != nil {
return nil, fmt.Errorf(
"letters.decoders.decodeContent: cannot decode raw-std-base64-encoded content: %w",
Expand All @@ -74,7 +73,7 @@ func decodeContent(
contentReader = bytes.NewReader(b)
case cteQuotedPrintable:
decoded := quotedprintable.NewReader(bytes.NewReader(contentBytes))
b, err := ioutil.ReadAll(decoded)
b, err := io.ReadAll(decoded)
if err != nil {
return nil, fmt.Errorf(
"letters.decoders.decodeContent: cannot decode quoted-printable-encoded content: %w",
Expand Down Expand Up @@ -113,7 +112,7 @@ func decodeInlineFile(part *multipart.Part, cte ContentTransferEncoding) (Inline
}

ifl.ContentID = strings.Trim(cid, "<>")
ifl.Data, err = ioutil.ReadAll(decoded)
ifl.Data, err = io.ReadAll(decoded)
if err != nil {
return ifl, fmt.Errorf(
"letters.decoders.decodeInlineFile: cannot read inline attachment data: %w",
Expand Down Expand Up @@ -149,7 +148,7 @@ func decodeAttachmentFileFromBody(body io.Reader, headers Headers, cte ContentTr

afl.ContentType = headers.ContentType
afl.ContentDisposition = headers.ContentDisposition
afl.Data, err = ioutil.ReadAll(decoded)
afl.Data, err = io.ReadAll(decoded)
if err != nil {
return afl, fmt.Errorf(
"letters.decoders.decodeAttachmentFileFromBody: cannot read attached file data: %w",
Expand Down Expand Up @@ -183,7 +182,7 @@ func decodeAttachedFileFromPart(part *multipart.Part, cte ContentTransferEncodin
err)
}

afl.Data, err = ioutil.ReadAll(decoded)
afl.Data, err = io.ReadAll(decoded)
if err != nil {
return afl, fmt.Errorf(
"letters.decoders.decodeAttachedFileFromPart: cannot read attached file data: %w",
Expand Down
3 changes: 1 addition & 2 deletions parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package letters
import (
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/mail"
Expand Down Expand Up @@ -358,7 +357,7 @@ func parseText(t io.Reader, e encoding.Encoding, cte ContentTransferEncoding) (s
err)
}

textBody, err := ioutil.ReadAll(reader)
textBody, err := io.ReadAll(reader)
if err != nil {
return "", fmt.Errorf(
"letters.parsers.parseText: cannot read plain text content: %w",
Expand Down
Loading