File: client_windows.go

package info (click to toggle)
docker.io 26.1.5%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,576 kB
  • sloc: sh: 5,748; makefile: 912; ansic: 664; asm: 228; python: 162
file content (25 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package client

import (
	"context"
	"net"
	"strings"

	winio "github.com/Microsoft/go-winio"
	"github.com/pkg/errors"
)

func dialer(ctx context.Context, address string) (net.Conn, error) {
	addrParts := strings.SplitN(address, "://", 2)
	if len(addrParts) != 2 {
		return nil, errors.Errorf("invalid address %s", address)
	}
	switch addrParts[0] {
	case "npipe":
		address = strings.Replace(addrParts[1], "/", "\\", -1)
		return winio.DialPipeContext(ctx, address)
	default:
		var d net.Dialer
		return d.DialContext(ctx, addrParts[0], addrParts[1])
	}
}