File: dial.go

package info (click to toggle)
golang-github-canonical-go-dqlite 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 712 kB
  • sloc: sh: 380; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 340 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package protocol

import (
	"context"
	"net"
	"strings"
)

// Dial function handling plain TCP and Unix socket endpoints.
func Dial(ctx context.Context, address string) (net.Conn, error) {
	family := "tcp"
	if strings.HasPrefix(address, "@") {
		family = "unix"
	}
	dialer := net.Dialer{}
	return dialer.DialContext(ctx, family, address)
}