bump to go 1.20 + fix some code issues

This commit is contained in:
2023-09-09 15:45:36 +02:00
parent c1551be07f
commit 2bc22b637d
6 changed files with 65 additions and 69 deletions
+4 -3
View File
@@ -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 {