ircd/addr.go

32 lines
521 B
Go
Raw Normal View History

2014-11-22 13:21:30 +00:00
package ircd
import (
"strings"
)
func AddrName(addr string) string {
parts := strings.SplitN(addr, "@", 2)
return parts[0]
}
func AddrHost(addr string) string {
parts := strings.SplitN(addr, "@", 2)
if len(parts) > 1 {
return parts[1]
}
return ""
}
func AddrSplit(addr string) (string, string) {
parts := strings.SplitN(addr, "@", 2)
if len(parts) > 1 {
return parts[0], parts[1]
}
return parts[0], ""
}
func AddrJoin(name string, host string) string {
return name + "@" + host
}
// vi:ts=4:sw=4:et