Browse Source

Added net.go Connect()

pull/1842/head
Jae Kwon 9 years ago
parent
commit
0424228e97
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      net.go

+ 14
- 0
net.go View File

@ -0,0 +1,14 @@
package common
import (
"net"
"strings"
)
// protoAddr: e.g. "tcp://127.0.0.1:8080" or "unix:///tmp/test.sock"
func Connect(protoAddr string) (net.Conn, error) {
parts := strings.SplitN(protoAddr, "://", 2)
proto, address := parts[0], parts[1]
conn, err := net.Dial(proto, address)
return conn, err
}

Loading…
Cancel
Save