MCPcopy Create free account
hub / github.com/derekbanas/Go-Tutorial / IsEmail

Function IsEmail

app2/testemail.go:8–18  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

6)
7
8func IsEmail(s string) (string, error) {
9 // Used a raw string here so I didn't have
10 // to double backslashes
11 r, _ := regexp.Compile(`[\w._%+-]{1,20}@[\w.-]{2,20}.[A-Za-z]{2,3}`)
12
13 if r.MatchString(s) {
14 return "Valid Email", nil
15 } else {
16 return "", fmt.Errorf("not a valid email")
17 }
18}

Callers 1

TestIsEmailFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsEmailFunction · 0.68