增加DNS域名管理

This commit is contained in:
刘祥超
2020-11-12 14:41:34 +08:00
parent a697ec65ac
commit a609a36795
16 changed files with 350 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
package domainutils
import (
"regexp"
"strings"
)
// 校验域名格式
func ValidateDomainFormat(domain string) bool {
pieces := strings.Split(domain, ".")
for _, piece := range pieces {
if !regexp.MustCompile(`^[a-z0-9-]+$`).MatchString(piece) {
return false
}
}
return true
}