mirror of
https://github.com/grafana/grafana.git
synced 2024-12-29 10:21:41 -06:00
5f6383a750
See, $ gometalinter --vendor --deadline 10m --disable-all --enable=golint ./... encoding.go:15:1⚠️ comment on exported function GetRandomString should be of the form "GetRandomString ..." (golint) encoding.go:30:1⚠️ exported function EncodePassword should have comment or be unexported (golint) encoding.go:35:1⚠️ comment on exported function EncodeMd5 should be of the form "EncodeMd5 ..." (golint) encoding.go:42:1⚠️ comment on exported function PBKDF2 should be of the form "PBKDF2 ..." (golint) encoding.go:80:1⚠️ exported function GetBasicAuthHeader should have comment or be unexported (golint) encoding.go:85:1⚠️ exported function DecodeBasicAuthHeader should have comment or be unexported (golint) encoding.go:105:1⚠️ exported function RandomHex should have comment or be unexported (golint) encryption.go:14:1⚠️ exported function Decrypt should have comment or be unexported (golint) encryption.go:39:1⚠️ exported function Encrypt should have comment or be unexported (golint) ip.go:7:1⚠️ exported function SplitIpPort should have comment or be unexported (golint) json.go:3:6⚠️ exported type DynMap should have comment or be unexported (golint) md5.go:22:1⚠️ comment on exported function Md5SumString should be of the form "Md5SumString ..." (golint) strings.go:10:1⚠️ exported function StringsFallback2 should have comment or be unexported (golint) strings.go:14:1⚠️ exported function StringsFallback3 should have comment or be unexported (golint) strings.go:27:1⚠️ exported function SplitString should have comment or be unexported (golint) strings.go:35:1⚠️ exported function GetAgeString should have comment or be unexported (golint) url.go:8:6⚠️ exported type UrlQueryReader should have comment or be unexported (golint) url.go:12:1⚠️ exported function NewUrlQueryReader should have comment or be unexported (golint) url.go:23:1⚠️ exported method UrlQueryReader.Get should have comment or be unexported (golint) url.go:32:1⚠️ exported function JoinUrlFragments should have comment or be unexported (golint) validation.go:16:1⚠️ exported function IsEmail should have comment or be unexported (golint)
20 lines
1.5 KiB
Go
20 lines
1.5 KiB
Go
package util
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
emailRegexPattern string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=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a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$"
|
|
)
|
|
|
|
var (
|
|
regexEmail = regexp.MustCompile(emailRegexPattern)
|
|
)
|
|
|
|
// IsEmail checks if a string is a valid email address.
|
|
func IsEmail(str string) bool {
|
|
return regexEmail.MatchString(strings.ToLower(str))
|
|
}
|