From 6c14ae2cee208a1075d128a5992526ea3f0a6313 Mon Sep 17 00:00:00 2001 From: matthew-pilot Date: Sat, 30 May 2026 16:32:35 +0000 Subject: [PATCH] docs(examples): recommend os.UserHomeDir() over hardcoded /tmp/pilot.sock (PILOT-298) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All five Go examples (client, echo, httpclient, secure, webserver) hardcode /tmp/pilot.sock as the default daemon socket path. On Linux this conflicts with the XDG_RUNTIME_DIR fallback (PILOT-151) and on macOS forfeits the SIP per-user /tmp guarantee in edge cases. Add a NOTE comment near each flag.String call recommending os.UserHomeDir() / XDG_RUNTIME_DIR alternatives. The hardcoded /tmp default is preserved for quick-start convenience — this is a documentation change only. Closes PILOT-298 --- go/client/main.go | 4 ++++ go/echo/main.go | 4 ++++ go/httpclient/main.go | 4 ++++ go/secure/main.go | 4 ++++ go/webserver/main.go | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/go/client/main.go b/go/client/main.go index 1faa2dd..081c6ef 100644 --- a/go/client/main.go +++ b/go/client/main.go @@ -13,6 +13,10 @@ import ( func main() { socketPath := flag.String("socket", "/tmp/pilot.sock", "daemon socket path") + // NOTE: On Linux, prefer os.UserHomeDir() or XDG_RUNTIME_DIR for the socket + // path (e.g. filepath.Join(os.UserHomeDir(), ".pilot", "daemon.sock")). + // The hardcoded /tmp default is fine for quick testing but may conflict + // with the per-user daemon socket on multi-user systems. target := flag.String("target", "", "target address (e.g. 0:0000.0000.0002:80)") message := flag.String("msg", "hello from pilot client", "message to send") flag.Parse() diff --git a/go/echo/main.go b/go/echo/main.go index 531b930..762e27b 100644 --- a/go/echo/main.go +++ b/go/echo/main.go @@ -11,6 +11,10 @@ import ( func main() { socketPath := flag.String("socket", "/tmp/pilot.sock", "daemon socket path") + // NOTE: On Linux, prefer os.UserHomeDir() or XDG_RUNTIME_DIR for the socket + // path (e.g. filepath.Join(os.UserHomeDir(), ".pilot", "daemon.sock")). + // The hardcoded /tmp default is fine for quick testing but may conflict + // with the per-user daemon socket on multi-user systems. port := flag.Uint("port", 7, "pilot port to listen on") raw := flag.Bool("raw", true, "raw echo (no prefix)") flag.Parse() diff --git a/go/httpclient/main.go b/go/httpclient/main.go index 08ae96c..632bce3 100644 --- a/go/httpclient/main.go +++ b/go/httpclient/main.go @@ -14,6 +14,10 @@ import ( func main() { socketPath := flag.String("socket", "/tmp/pilot.sock", "daemon socket path") + // NOTE: On Linux, prefer os.UserHomeDir() or XDG_RUNTIME_DIR for the socket + // path (e.g. filepath.Join(os.UserHomeDir(), ".pilot", "daemon.sock")). + // The hardcoded /tmp default is fine for quick testing but may conflict + // with the per-user daemon socket on multi-user systems. target := flag.String("target", "", "target address (e.g. 0:0000.0000.0002)") port := flag.Uint("port", 80, "target port") path := flag.String("path", "/status", "HTTP path to request") diff --git a/go/secure/main.go b/go/secure/main.go index d0552d3..8fdf1cb 100644 --- a/go/secure/main.go +++ b/go/secure/main.go @@ -15,6 +15,10 @@ import ( func main() { socketPath := flag.String("socket", "/tmp/pilot.sock", "daemon socket path") + // NOTE: On Linux, prefer os.UserHomeDir() or XDG_RUNTIME_DIR for the socket + // path (e.g. filepath.Join(os.UserHomeDir(), ".pilot", "daemon.sock")). + // The hardcoded /tmp default is fine for quick testing but may conflict + // with the per-user daemon socket on multi-user systems. mode := flag.String("mode", "server", "server or client") target := flag.String("target", "", "target address for client mode") msg := flag.String("msg", "hello secure channel", "message to send in client mode") diff --git a/go/webserver/main.go b/go/webserver/main.go index de67962..dacf56c 100644 --- a/go/webserver/main.go +++ b/go/webserver/main.go @@ -13,6 +13,10 @@ import ( func main() { socketPath := flag.String("socket", "/tmp/pilot.sock", "daemon socket path") + // NOTE: On Linux, prefer os.UserHomeDir() or XDG_RUNTIME_DIR for the socket + // path (e.g. filepath.Join(os.UserHomeDir(), ".pilot", "daemon.sock")). + // The hardcoded /tmp default is fine for quick testing but may conflict + // with the per-user daemon socket on multi-user systems. port := flag.Uint("port", 80, "pilot port to listen on") flag.Parse()