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

feat: go 1.19 compatibility #464

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-and-deploy.yml
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
go: [ '1.14', '1.15', '1.16', '1.17' ]
go: [ '1.14', '1.15', '1.16', '1.17', '1.18', '1.19' ]
env:
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -39,6 +39,8 @@ This library supports the following Go implementations:
* Go 1.15
* Go 1.16
* Go 1.17
* Go 1.18
* Go 1.19

## Prerequisites

Expand Down
7 changes: 3 additions & 4 deletions helpers/inbound/inbound.go
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime"
"mime/multipart"
"net/http"
Expand Down Expand Up @@ -184,22 +183,22 @@ func (email *ParsedEmail) parseRawEmail(rawEmail string) error {
break
}
header := emailBodyPart.Header.Get("Content-Type")
b, err := ioutil.ReadAll(emailPart)
b, err := io.ReadAll(emailPart)
if err != nil {
return err
}
email.Body[header] = string(b)
}

} else if emailPart.FileName() != "" {
b, err := ioutil.ReadAll(emailPart)
b, err := io.ReadAll(emailPart)
if err != nil {
return err
}
email.Attachments[emailPart.FileName()] = b
} else {
header := emailPart.Header.Get("Content-Type")
b, err := ioutil.ReadAll(emailPart)
b, err := io.ReadAll(emailPart)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions helpers/inbound/inbound_test.go
Expand Up @@ -3,16 +3,16 @@ package inbound
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func createRequest(filename string) *http.Request {
file, err := ioutil.ReadFile(filename)
file, err := os.ReadFile(filename)
if err != nil {
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions sendgrid_test.go
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -19,7 +18,7 @@ import (
)

func TestLicenseYear(t *testing.T) {
d, err := ioutil.ReadFile("LICENSE")
d, err := os.ReadFile("LICENSE")
assert.Nil(t, err, "Cannot read the LICENSE file")
l := fmt.Sprintf("Copyright (C) %v, Twilio SendGrid, Inc.", time.Now().Year())
assert.True(t, strings.Contains(string(d), l), fmt.Sprintf("License date range is not correct, it should be: %v", l))
Expand Down
6 changes: 3 additions & 3 deletions use-cases/attachments-with-mailer-helper.md
Expand Up @@ -34,7 +34,7 @@ func main() {

// read/attach .txt file
a_txt := mail.NewAttachment()
dat, err := ioutil.ReadFile("testing.txt")
dat, err := io.ReadFile("testing.txt")
if err != nil {
fmt.Println(err)
}
Expand All @@ -46,7 +46,7 @@ func main() {

// read/attach .pdf file
a_pdf := mail.NewAttachment()
dat, err = ioutil.ReadFile("testing.pdf")
dat, err = io.ReadFile("testing.pdf")
if err != nil {
fmt.Println(err)
}
Expand All @@ -58,7 +58,7 @@ func main() {

// read/attach inline .jpg file
a_jpg := mail.NewAttachment()
dat, err = ioutil.ReadFile("testing.jpg")
dat, err = io.ReadFile("testing.jpg")
if err != nil {
fmt.Println(err)
}
Expand Down