bump to go 1.20 + fix some code issues
This commit is contained in:
+4
-3
@@ -3,11 +3,12 @@ package mail
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Email struct {
|
||||
Path string
|
||||
Sender string `json:"sender"`
|
||||
Receivers []string `json:"receivers"`
|
||||
Subject string `json:"subject"`
|
||||
@@ -26,9 +27,9 @@ func NewEmail(sender string, receivers []string, subject, content string) Email
|
||||
func FromJSON(path string) (Email, error) {
|
||||
var mail Email
|
||||
|
||||
content, err := ioutil.ReadFile(path)
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return mail, err
|
||||
return mail, fmt.Errorf("%w, unable to read the file: %s", err, path)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(content, &mail); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user