Skip to content

Commit

Permalink
Minor improvements, upgraded deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Dec 28, 2019
1 parent 141eb30 commit 777c621
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func main() {

## Maintainers

[@MrZ1836](https://github.com/mrz1836)
[@MrZ](https://github.com/mrz1836)

## Contributing

Expand Down
3 changes: 1 addition & 2 deletions aws_ses.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ func (m *MailService) sendWithAwsSes(email *Email) (err error) {

// Create the email buffer and pass to the ses service
var buf *bytes.Buffer
buf, err = mail.MimeBuf()
if err != nil {
if buf, err = mail.MimeBuf(); err != nil {
return err
}

Expand Down
16 changes: 5 additions & 11 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ func (e *Email) ApplyTemplates(htmlTemplate *template.Template, textTemplate *te
if htmlTemplate != nil {

// Read the struct into the HTML buffer
err = htmlTemplate.ExecuteTemplate(&buffer, htmlTemplate.Name(), emailData)
if err != nil {
if err = htmlTemplate.ExecuteTemplate(&buffer, htmlTemplate.Name(), emailData); err != nil {
return
}

Expand All @@ -80,8 +79,7 @@ func (e *Email) ApplyTemplates(htmlTemplate *template.Template, textTemplate *te
if textTemplate != nil {

// Read the struct into the text buffer
err = textTemplate.ExecuteTemplate(&buffer, textTemplate.Name(), emailData)
if err != nil {
if err = textTemplate.ExecuteTemplate(&buffer, textTemplate.Name(), emailData); err != nil {
return
}

Expand All @@ -105,9 +103,7 @@ func (e *Email) ParseHTMLTemplate(htmlLocation string) (htmlTemplate *template.T

// Read HTML template file
var tempBytes []byte
tempBytes, err = ioutil.ReadFile(htmlLocation)
if err != nil {
err = fmt.Errorf("")
if tempBytes, err = ioutil.ReadFile(htmlLocation); err != nil {
return
}

Expand All @@ -117,14 +113,12 @@ func (e *Email) ParseHTMLTemplate(htmlLocation string) (htmlTemplate *template.T
// Inject styles
tempBytes = bytes.Replace(tempBytes, []byte("{{.Styles}}"), e.CSS, -1)
var tempString string
tempString, err = inliner.Inline(string(tempBytes))
if err != nil {
if tempString, err = inliner.Inline(string(tempBytes)); err != nil {
return
}

// Replace the string with template
htmlTemplate, err = e.ParseTemplate(htmlLocation)
if err != nil {
if htmlTemplate, err = e.ParseTemplate(htmlLocation); err != nil {
return
}
_, err = htmlTemplate.Parse(tempString)
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ go 1.13

require (
github.com/PuerkitoBio/goquery v1.5.0 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/aymerick/douceur v0.2.0
github.com/domodwyer/mailyak v3.1.1+incompatible
github.com/gorilla/css v1.0.0 // indirect
github.com/mattbaird/gochimp v0.0.0-20180111040707-a267553896d1
github.com/mrz1836/postmark v1.2.2
github.com/mrz1836/postmark v1.2.3
github.com/sourcegraph/go-ses v0.0.0-20160405160939-6bd8d17cf7c1
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 // indirect
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
)
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP
github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/domodwyer/mailyak v3.1.1+incompatible h1:oPtXn3+56LEFbdqH0bpuPRsqtijW9l2POpQe9sTUsSI=
Expand All @@ -10,14 +12,16 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/mattbaird/gochimp v0.0.0-20180111040707-a267553896d1 h1:dkQj0GZch2rk/ODbwy17kP5tbmPcMGiw1KYOi6Ni0/w=
github.com/mattbaird/gochimp v0.0.0-20180111040707-a267553896d1/go.mod h1:UaYd2gciRA1AoYEN6S+EiSNFK/0XHj9e1Wgloicgh6s=
github.com/mrz1836/postmark v1.2.2 h1:SP0FihxskYraC1h+4Oxv1f4d3Csj3nMQ9PLyr1kQqdc=
github.com/mrz1836/postmark v1.2.2/go.mod h1:mpI6b64GBYN7sNz0BQEaRtHK+D5546YDNQp9FtCEHaM=
github.com/mrz1836/postmark v1.2.3 h1:yvi8UesSpUhHc3fB30Yhe+fr78/0j0rbBATOVgz3GnM=
github.com/mrz1836/postmark v1.2.3/go.mod h1:JCDGKzJvuZGVcyhNxyRfAKp9gIDnGrCd+7nOXMaLiR0=
github.com/sourcegraph/go-ses v0.0.0-20160405160939-6bd8d17cf7c1 h1:2Ndulo7XO8FH6BqX62+FG9Hvl1uOBwDSrE6BAkTNHtA=
github.com/sourcegraph/go-ses v0.0.0-20160405160939-6bd8d17cf7c1/go.mod h1:7pQ21TK+WkdBIwDfMovYhmNyGeBduRj3S089GgpNQ3g=
goji.io v2.0.2+incompatible h1:uIssv/elbKRLznFUy3Xj4+2Mz/qKhek/9aZQDUMae7c=
goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk=
golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6 changes: 2 additions & 4 deletions mandrill.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func (m *MailService) sendWithMandrill(email *Email) (err error) {
// Read all content from the attachment
reader := bufio.NewReader(attachment.FileReader)
var content []byte
content, err = ioutil.ReadAll(reader)
if err != nil {
if content, err = ioutil.ReadAll(reader); err != nil {
return
}

Expand All @@ -98,8 +97,7 @@ func (m *MailService) sendWithMandrill(email *Email) (err error) {

// Execute the send
var sendResponse []gochimp.SendResponse
sendResponse, err = m.mandrillService.MessageSend(message, false)
if err != nil {
if sendResponse, err = m.mandrillService.MessageSend(message, false); err != nil {
return
}

Expand Down
6 changes: 2 additions & 4 deletions postmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ func (m *MailService) sendWithPostmark(email *Email) (err error) {
// Read all content from the attachment
reader := bufio.NewReader(attachment.FileReader)
var content []byte
content, err = ioutil.ReadAll(reader)
if err != nil {
if content, err = ioutil.ReadAll(reader); err != nil {
return
}

Expand All @@ -94,8 +93,7 @@ func (m *MailService) sendWithPostmark(email *Email) (err error) {

// Send the email
var resp postmark.EmailResponse
resp, err = m.postmarkService.SendEmail(postmarkEmail)
if err != nil {
if resp, err = m.postmarkService.SendEmail(postmarkEmail); err != nil {
return
}

Expand Down

0 comments on commit 777c621

Please sign in to comment.