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/ },
]
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))"
```
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",