From 89b666b79a556ce905d8f1c7d52daed2c11a8b6c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 21:52:31 -0600 Subject: [PATCH 1/3] docs(go) Select the pane I/O cleanup excerpt why: The guide matched both the session and private server teardown. The Go documentation build could no longer render the cleanup example. what: - Select the session cleanup by its context and Kill call. - Explain how the Go example selects a named socket or an exact path. - Describe who stops the private server and removes its directory. --- .../ports/go/examples/attach-and-send-keys.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/site/src/content/docs/ports/go/examples/attach-and-send-keys.md b/site/src/content/docs/ports/go/examples/attach-and-send-keys.md index 676999aaa..f3bbb2685 100644 --- a/site/src/content/docs/ports/go/examples/attach-and-send-keys.md +++ b/site/src/content/docs/ports/go/examples/attach-and-send-keys.md @@ -27,17 +27,18 @@ the same sequence in shell. [Source](#where-this-comes-from) names the file. Every call that reaches tmux takes a `context.Context`. The program gives the whole run 30 seconds, so a wait that never matches ends with `context.DeadlineExceeded` instead of blocking forever. `tmux.NewServer` -validates a `tmux.ServerOptions` and does not start tmux. +configures a server handle. The first session starts tmux if the selected +server is absent. `ServerOptions.SocketName` selects a named socket, like `-L`, and -`ServerOptions.ConfigFile` set to `os.DevNull` keeps your tmux configuration -file out, like `-f /dev/null`. Choose a socket name that no other tmux uses, -because [cleanup](#8-clean-up) ends the server on that socket. With an unused -name, the program neither touches nor is changed by the tmux you already use. +`ServerOptions.SocketPath` selects a socket by path, like `-S`. +Use a socket dedicated to the example so [cleanup](#8-clean-up) affects only +its own server. Setting `ServerOptions.ConfigFile` to `os.DevNull` keeps your +tmux configuration out, like `-f /dev/null`. The native step is [Choose a private socket](/tmux/examples/attach-and-send-keys/#1-choose-a-private-socket). The server goes to `run`, so a test can pass in an isolated one. -```go file="examples/pane-io/main.go" from="ctx, cancel := context.WithTimeout" to="return run(ctx, server)" +```go file="examples/pane-io/main.go" from="server, err := tmux.NewServer" to="return run(ctx, server)" ``` @@ -138,9 +139,11 @@ then the session is killed. The kill uses a context of its own that the run's cancellation cannot end, with one second to finish, so a deadline that has passed does not skip the cleanup, and `errors.Join` reports a cleanup failure beside the original error. With the default `exit-empty` setting, the private -server exits when its last session is gone. +server exits when its last session is gone. When the example owns a socket +directory, it also defers stopping its server. It removes the directory once +the stop succeeds or tmux reports the server is already gone. -```go file="examples/pane-io/main.go" from="=\tdefer func() {" to="=\t}()" +```go file="examples/pane-io/main.go" from="cleanupCtx, cleanupCancel := context.WithTimeout" to="err = errors.Join(err, session.Kill(cleanupCtx))" ``` From 63d7751a72303b3f098617c6b9d2bb9c081724f5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 22:32:01 -0600 Subject: [PATCH 2/3] docs(go) Index the pane I/O socket path why: The attach guide now explains the exact socket path. Its API backlink still pointed at the general server options type. what: - Regenerate the guide index from the staged documentation sources. - Move the attach guide backlink to ServerOptions.SocketPath. --- site/src/data/mentions.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/site/src/data/mentions.json b/site/src/data/mentions.json index 9f6685775..dc0c4a5cb 100644 --- a/site/src/data/mentions.json +++ b/site/src/data/mentions.json @@ -6125,13 +6125,6 @@ "title": "Server, session, window, pane", "section": "concepts" }, - { - "port": "go", - "symbol": "tmux.ServerOptions", - "page": "/go/latest/examples/attach-and-send-keys/", - "title": "Attach and send keys", - "section": "examples" - }, { "port": "go", "symbol": "tmux.ServerOptions", @@ -6167,6 +6160,13 @@ "title": "Socket and servers", "section": "topics" }, + { + "port": "go", + "symbol": "tmux.ServerOptions.SocketPath", + "page": "/go/latest/examples/attach-and-send-keys/", + "title": "Attach and send keys", + "section": "examples" + }, { "port": "go", "symbol": "tmux.ServerOptions.SocketPath", From 5d694a833605d9ba79248c8eaa231415e1895fba Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 22:49:31 -0600 Subject: [PATCH 3/3] test(examples) Keep missing-file checks focused why: The missing-file case stopped when a Go example changed its setup line. The checker never saw the missing source file. what: - Change the file named by the first Go excerpt in the attach guide. - Keep its live source anchors and require the missing-file error. --- scripts/check-example-blocks.negative.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-example-blocks.negative.mjs b/scripts/check-example-blocks.negative.mjs index 453ea4b09..463d31ace 100644 --- a/scripts/check-example-blocks.negative.mjs +++ b/scripts/check-example-blocks.negative.mjs @@ -58,7 +58,7 @@ const cases = [ { name: 'an excerpt whose range ends inside a block', page: attach, find: 'from="found=no" to="done"', replace: 'from="found=no" to="fi"', trips: /opens do it never closes/ }, { name: 'an excerpt that carries its own text', page: attach, find: 'from="has-session"\n```', replace: 'from="has-session"\ntmux has-session\n```', trips: /carries no text of its own/ }, { name: 'an excerpt of a block the page does not have', page: attach, find: 'excerpt="send-command.sh" from="has-session"', replace: 'excerpt="other.sh" from="has-session"', trips: /no code block titled "other\.sh"/ }, - { name: 'a Go excerpt of a file missing from the example cache', page: goAttach, find: 'file="examples/pane-io/main.go" from="ctx, cancel', replace: 'file="examples/gone/main.go" from="ctx, cancel', trips: /examples\/gone\/main\.go is not in the go example cache/ }, + { name: 'a Go excerpt of a file missing from the example cache', page: goAttach, find: '```go file="examples/pane-io/main.go" from="', replace: '```go file="examples/gone/main.go" from="', trips: /examples\/gone\/main\.go is not in the go example cache/ }, { name: 'a port page linking itself as its native version', page: goAttach, find: '](/tmux/examples/attach-and-send-keys/)', replace: '](/examples/attach-and-send-keys/)', trips: /links to the page itself/ }, { name: 'a Go file inclusion missing from the example cache', page: goAttach, find: '```go file="examples/pane-io/main.go" height="24"\n```', replace: '```go file="examples/gone/main.go" height="24"\n```', trips: /examples\/gone\/main\.go is not in the example cache/ }, ]