I'm having trouble pulling out the domain for emails. I've tried using variations of
u, _ := url.Parse(email)
and other parsing from the standard library, but nothing that seems to parse: user@gmail.com into separate parts.
I've also tried net.SplitHostPort with no luck.
I don't want to get create a function which gets the len and separate to get substring after @ symbol if possible.
Does anyone have any ideas to do this?
Thanks!
Here's an example I concocted from the golang documentation:
package main
import (
"fmt"
"strings"
)
func main() {
email := "foo@bar.com"
components := strings.Split(email, "@")
username, domain := components[0], components[1]
fmt.Printf("Username: %s, Domain: %s
", username, domain)
}