2021-01-18 19:00:32 +00:00
|
|
|
package funcs
|
|
|
|
|
|
|
|
import (
|
2021-11-07 17:51:39 +00:00
|
|
|
"net"
|
2021-01-18 19:00:32 +00:00
|
|
|
)
|
|
|
|
|
2021-11-07 17:51:39 +00:00
|
|
|
// IsUnix tests if the address is an unix address. It returns false if its an tcp address.
|
|
|
|
func IsUnix(address string) bool {
|
|
|
|
if IsTCP(address) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := net.ResolveUnixAddr("unix", address); err == nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsTCP tests if the address is an tcp address
|
|
|
|
func IsTCP(address string) bool {
|
|
|
|
_, err := net.ResolveTCPAddr("tcp", address)
|
|
|
|
if err == nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|