Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save namp10010/83820a59dc8d419e1aed49d343ee82b2 to your computer and use it in GitHub Desktop.
Save namp10010/83820a59dc8d419e1aed49d343ee82b2 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
myEmail := &Email{}
myEmail.withFrom("sender").
withTo("recipient").
withSubject("hello").
withBody("howdy?")
fmt.Println("my email: ", *myEmail)
}
type Email struct {
from string
to string
subject string
body string
}
func (e *Email) withFrom(fr string) *Email {
e.from = fr
return e
}
func (e *Email) withTo(to string) *Email {
e.to = to
return e
}
func (e *Email) withSubject(s string) *Email {
e.subject = s
return e
}
func (e *Email) withBody(b string) *Email {
e.body = b
return e
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment