import ( "net/mail" ) func main() { addr, err := mail.ParseAddress("[email protected]") if err != nil { panic(err) } fmt.Println(addr.User) fmt.Println(addr.Address) fmt.Println(addr.Name) }
import ( "net/mail" ) func main() { addr := &mail.Address{ Name: "John Doe", Address: "[email protected]", } fmt.Println(addr.String()) }In this example, we create an Address object using the `&mail.Address{}` syntax. We set the name and address fields of the object and then convert it to a string representation using the `String()` method. The package library for these examples is Go's built-in `net/mail` package.