From d9132d2a5211f4b0d7ac263f0d30589ca161a24f Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 8 Apr 2024 14:24:42 -0700 Subject: [PATCH] net: add ResolveUnixAddr Signed-off-by: Christian Stewart --- unixsock.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/unixsock.go b/unixsock.go index 849789b..f77f558 100644 --- a/unixsock.go +++ b/unixsock.go @@ -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 @@ -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) + } +}