-
Notifications
You must be signed in to change notification settings - Fork 581
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
Should Message be an interface? #5
Comments
What kind of function do you need exactly? The previous version of Gomail exposed a |
I had wrapped up gomail.Message in my own struct:
to allow for validation of the message before sending (as I mention in issue #6). I can't pass this to gomail.Mailer.Send() directly as it's not the right type. I thought an interface might be better here as all the Mailer needs is something it can call Export() on. (or maybe just pass in a *mail.Message directly?) |
Have you tried something like that? package main
import "fmt"
type Message struct{}
type MessageWrapper struct {
*Message
}
func main() {
m := new(MessageWrapper)
Send(m.Message)
}
func Send(m *Message) {
fmt.Println("Message sent!")
} |
Yeah this totally works. I guess my question was more if it might make some use cases cleaner to have it be an Interface. |
It seems like it might be a good idea to make Message an interface in gomail rather than a concrete struct. This would allow users of the library to use the sending functionality separately from the message creation functionality.
I'm was looking at switching over my rss mailer (https://github.com/hobeone/rss2go) to use gomail and ran into this. I could rework my mailer to use gomail.Message directly but I thought that maybe this pointed out a way to make gomail better.
The text was updated successfully, but these errors were encountered: