Convert FromAddress to use TextUnmarshaler

This commit is contained in:
Melon 2024-09-21 16:08:07 +01:00
parent f84a67ebec
commit 80dd3b55d1
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -1,17 +1,18 @@
package simplemail
import (
"encoding"
"encoding/json"
"net/mail"
"github.com/emersion/go-message/mail"
)
type FromAddress struct {
*mail.Address
}
var _ json.Unmarshaler = &FromAddress{}
var _ encoding.TextUnmarshaler = &FromAddress{}
func (f *FromAddress) UnmarshalJSON(b []byte) error {
func (f *FromAddress) UnmarshalText(b []byte) error {
var a string
err := json.Unmarshal(b, &a)
if err != nil {