improve: 使用标准项目结构

This commit is contained in:
Mmx233
2023-03-01 18:58:11 +08:00
parent cb11426bd6
commit 3c63e9ddc3
29 changed files with 178 additions and 183 deletions

View File

@@ -0,0 +1,9 @@
package dnsUtil
import (
"github.com/mitchellh/mapstructure"
)
func DecodeConfig(conf map[string]interface{}, output interface{}) error {
return mapstructure.Decode(conf, output)
}

View File

@@ -0,0 +1,18 @@
package dnsUtil
import (
"errors"
"strings"
)
func DecodeDomain(domain string) (subStr string, rootDomain string, e error) {
t := strings.Split(domain, ".")
if len(t) == 1 {
return "", "", errors.New("域名不合法")
} else if len(t) == 2 {
return "@", domain, nil
}
l := len(t)
return strings.Join(t[:l-2], "."), strings.Join(t[l-2:l], "."), nil
}