add hosts support for dns

This commit is contained in:
ginuerzh
2022-01-19 16:33:27 +08:00
parent 1e613fc2e6
commit f357117056
11 changed files with 212 additions and 53 deletions

View File

@ -105,7 +105,10 @@ func GetString(md Metadata, key string) (v string) {
}
func GetStrings(md Metadata, key string) (ss []string) {
if v, _ := md.Get(key).([]interface{}); len(v) > 0 {
switch v := md.Get(key).(type) {
case []string:
ss = v
case []interface{}:
for _, vv := range v {
if s, ok := vv.(string); ok {
ss = append(ss, s)