dialer_unix.go 673 B

123456789101112131415161718192021222324252627282930313233343536
  1. // +build !windows
  2. package dialer
  3. import (
  4. "fmt"
  5. "net"
  6. "os"
  7. "strings"
  8. "syscall"
  9. "time"
  10. )
  11. // DialAddress returns the address with unix:// prepended to the
  12. // provided address
  13. func DialAddress(address string) string {
  14. return fmt.Sprintf("unix://%s", address)
  15. }
  16. func isNoent(err error) bool {
  17. if err != nil {
  18. if nerr, ok := err.(*net.OpError); ok {
  19. if serr, ok := nerr.Err.(*os.SyscallError); ok {
  20. if serr.Err == syscall.ENOENT {
  21. return true
  22. }
  23. }
  24. }
  25. }
  26. return false
  27. }
  28. func dialer(address string, timeout time.Duration) (net.Conn, error) {
  29. address = strings.TrimPrefix(address, "unix://")
  30. return net.DialTimeout("unix", address, timeout)
  31. }