From 3211cb9802344f37a243bc81d005fb6e97f4f8f5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 12 Aug 2022 11:52:17 -0400 Subject: [PATCH] nettest: fix Unix socket test on macOS The macOS temp directory name is so long that it makes for socket names that are far too long. Fixes golang/go#54416. Change-Id: Id09cb5af6122227132a9be1e8101ce3450af09e5 Reviewed-on: https://go-review.googlesource.com/c/net/+/423039 TryBot-Result: Gopher Robot Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Auto-Submit: Russ Cox Run-TryBot: Russ Cox --- nettest/nettest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nettest/nettest.go b/nettest/nettest.go index ae5413b23..6918f2c36 100644 --- a/nettest/nettest.go +++ b/nettest/nettest.go @@ -218,7 +218,11 @@ func NewLocalPacketListener(network string) (net.PacketConn, error) { // LocalPath returns a local path that can be used for Unix-domain // protocol testing. func LocalPath() (string, error) { - f, err := ioutil.TempFile("", "go-nettest") + dir := "" + if runtime.GOOS == "darwin" { + dir = "/tmp" + } + f, err := ioutil.TempFile(dir, "go-nettest") if err != nil { return "", err }