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
might be cool? #5
Comments
You could just call the relevant functions in a goroutine in the client code, right? |
I'm by no means an expert (and I hope someone with more knowledge can comment), but this is what I would do as well. I believe it would make it more difficult for people to use the library and catch the error if it was run as a goroutine internally. I'll keep the issue open until (hopefully) we get a couple more responses. |
You're right. The correct way would be to let the client code decide: e := email.NewEmail()
// Setup email
go e.Send("smtp.gmail.com:587", smtp.PlainAuth("", "test@gmail.com", "password123", "smtp.gmail.com")) Or you can of course create your own function for it: func sendEmail(e *email.Email) {
e.Send("smtp.gmail.com:587", smtp.PlainAuth("", "test@gmail.com", "password123", "smtp.gmail.com"))
}
func main() {
e := email.NewEmail()
// Setup email
go sendEmail(e)
} This is just pseudo code. I haven't tested it but I think it should work |
It appears the consensus is to do it via client code. I agree, as this will help keep the Send() function easy to implement and maintain. It should be noted that, again, Send() is not at all the only way to send an email. The important part of this package is the type management and the Bytes() function, which does a lot of leg work. Feel free to reopen as needed, but for now I am going to consider this issue to be closed. Thanks again for bringing this up, and to everyone for the input. |
Sorry for opening this up again. I'm working on some email-critical functionality. Currently to know whether a So, is there some suggested way to run |
Might be cool if the Send mech had a way to do this in a go routine? to avoid blocking code using the package?
I would think we need some community guidance about whether the go routines should inside the packages or expected to be done by the users of the package...
opinion?
The text was updated successfully, but these errors were encountered: