Skip to content

Commit d9132d2

Browse files
paralindeadprogram
authored andcommitted
net: add ResolveUnixAddr
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent a794174 commit d9132d2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

unixsock.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ package net
1212
// BUG(mikio): On Windows, methods and functions related to UnixConn
1313
// and UnixListener don't work for "unixgram" and "unixpacket".
1414

15+
// BUG(paralin): On TinyGo, Unix sockets are not implemented.
16+
1517
// UnixAddr represents the address of a Unix domain socket end point.
1618
type UnixAddr struct {
1719
Name string
@@ -41,3 +43,18 @@ func (a *UnixAddr) opAddr() Addr {
4143
}
4244
return a
4345
}
46+
47+
// ResolveUnixAddr returns an address of Unix domain socket end point.
48+
//
49+
// The network must be a Unix network name.
50+
//
51+
// See func [Dial] for a description of the network and address
52+
// parameters.
53+
func ResolveUnixAddr(network, address string) (*UnixAddr, error) {
54+
switch network {
55+
case "unix", "unixgram", "unixpacket":
56+
return &UnixAddr{Name: address, Net: network}, nil
57+
default:
58+
return nil, UnknownNetworkError(network)
59+
}
60+
}

0 commit comments

Comments
 (0)