2
0
mirror of https://github.com/namecoin/ncdns synced 2024-11-11 19:10:43 +00:00
ncdns/util/util.go

16 lines
344 B
Go
Raw Normal View History

2014-10-21 20:30:19 +00:00
package util
import "strings"
// Split a domain name a.b.c.d.e into parts a (the head) and b.c.d.e (the rest).
func SplitDomainHead(name string) (head string, rest string, err error) {
parts := strings.Split(name, ".")
head = parts[len(parts)-1]
if len(parts) >= 2 {
rest = strings.Join(parts[0:len(parts)-1], ".")
}
return
}