Skip to content

Commit

Permalink
net: add ResolveUnixAddr
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin authored and deadprogram committed Apr 13, 2024
1 parent a794174 commit d9132d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions unixsock.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ package net
// BUG(mikio): On Windows, methods and functions related to UnixConn
// and UnixListener don't work for "unixgram" and "unixpacket".

// BUG(paralin): On TinyGo, Unix sockets are not implemented.

// UnixAddr represents the address of a Unix domain socket end point.
type UnixAddr struct {
Name string
Expand Down Expand Up @@ -41,3 +43,18 @@ func (a *UnixAddr) opAddr() Addr {
}
return a
}

// ResolveUnixAddr returns an address of Unix domain socket end point.
//
// The network must be a Unix network name.
//
// See func [Dial] for a description of the network and address
// parameters.
func ResolveUnixAddr(network, address string) (*UnixAddr, error) {
switch network {
case "unix", "unixgram", "unixpacket":
return &UnixAddr{Name: address, Net: network}, nil
default:
return nil, UnknownNetworkError(network)
}
}

0 comments on commit d9132d2

Please sign in to comment.