misc

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: GPL-3.0 Imports: 1 Imported by: 1

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

func IsEmailValid(email string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL