package daemonconn import ( "net" ) const DefaultUnixSocketPath = "/tmp/liberum.sock" func UnixSocketListen(socketPath string) (<-chan DaemonConn, error) { listener, err := net.Listen("unix", "/tmp/liberum.sock") if err != nil { return nil, err } connChan := make(chan DaemonConn, 32) go func() { var conn net.Conn for conn, err = listener.Accept(); err == nil; { connChan <- FromConn(conn) } }() return connChan, err } func UnixSocketConnect(socketPath string) (DaemonConn, error) { conn, err := net.Dial("unix", DefaultUnixSocketPath) if err != nil { return DaemonConn{}, err } return FromConn(conn), nil }