Documentation
¶
Overview ¶
Package misc contains some miscellaneous functions and constants that don't really fit elsewhere.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // EmailValidation (const) EmailValidation = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$") )
Functions ¶
func IsEmailValid ¶
IsEmailValid checks if the given email is valid using regex only.
Identical to the function found on this page: https://golangcode.com/validate-an-email-address/.
Example ¶
Check if the email:
test@example.com
Is valid and then check whether some normal text is valid.
// Valid example
e := "test@example.com"
if IsEmailValid(e) {
fmt.Println(e + " is a valid email")
}
// Invalid example
if !IsEmailValid("just text") {
fmt.Println("not a valid email")
}
Output: test@example.com is a valid email not a valid email
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.