Remove dead IsStdoutTerminal() and simplify containsAny test helper#1494
Merged
Remove dead IsStdoutTerminal() and simplify containsAny test helper#1494
IsStdoutTerminal() and simplify containsAny test helper#1494Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review Go module golang.org/x/term for usage in gh-aw
Remove dead Feb 28, 2026
IsStdoutTerminal() and simplify containsAny test helper
Contributor
There was a problem hiding this comment.
Pull request overview
Removes unused terminal-detection API from the internal TTY wrapper and simplifies a test helper by using the standard library, aligning with the recent golang.org/x/term module review findings.
Changes:
- Removed dead exported function
IsStdoutTerminal()frominternal/tty. - Simplified
containsAnytest helper to usestrings.Contains.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/tty/tty.go | Removes unused exported stdout TTY helper, leaving stderr TTY detection intact. |
| internal/tty/container_test.go | Replaces manual substring search logic in containsAny with strings.Contains. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two quick-win cleanups from the
golang.org/x/termmodule review.Changes
internal/tty/tty.go: RemoveIsStdoutTerminal()— exported but never called anywhere in the project.IsStderrTerminal()(used by the logger) is retained.internal/tty/container_test.go: Replace hand-rolled substring search in thecontainsAnyhelper withstrings.Contains:Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build609076577/b298/launcher.test /tmp/go-build609076577/b298/launcher.test -test.testlogfile=/tmp/go-build609076577/b298/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 64/src/internal/fmtsort/sort.go x_amd64/compile user.name 7533934/b010/(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build609076577/b280/config.test /tmp/go-build609076577/b280/config.test -test.testlogfile=/tmp/go-build609076577/b280/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 40tls/fipstls.go ache/go/1.25.7/x64/pkg/tool/linu-o credential.helpe/opt/hostedtoolcache/go/1.25.7/x64/pkg/tool/linux_amd64/vet(dns block)nonexistent.local/tmp/go-build609076577/b298/launcher.test /tmp/go-build609076577/b298/launcher.test -test.testlogfile=/tmp/go-build609076577/b298/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 64/src/internal/fmtsort/sort.go x_amd64/compile user.name 7533934/b010/(dns block)slow.example.com/tmp/go-build609076577/b298/launcher.test /tmp/go-build609076577/b298/launcher.test -test.testlogfile=/tmp/go-build609076577/b298/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/cgo 64/src/internal/fmtsort/sort.go x_amd64/compile user.name 7533934/b010/(dns block)this-host-does-not-exist-12345.com/tmp/go-build609076577/b307/mcp.test /tmp/go-build609076577/b307/mcp.test -test.testlogfile=/tmp/go-build609076577/b307/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true arm.go --local x_amd64/compile user.name /gc(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>[go-fan] Go Module Review: golang.org/x/term</issue_title>
<issue_description># 🐹 Go Fan Report: golang.org/x/term
Module Overview
golang.org/x/termis the official Go extended library for cross-platform terminal handling. It provides terminal detection, mode switching (raw mode), terminal sizing, password reading, and a full line-editing terminal emulator. It supports Linux, macOS, Windows, and Plan9.Current Usage in gh-aw
The module is used exclusively through the thin
internal/ttywrapper package.internal/tty/tty.go)term.IsTerminal(int(os.Stderr.Fd()))— checks stderr is a TTY, used at init ininternal/logger/logger.goto enable ANSI color outputterm.IsTerminal(int(os.Stdout.Fd()))— defined asIsStdoutTerminal()in the tty package but never called anywhere in the projectResearch Findings
golang.org/x/termv0.38.0 is the current version in use. The most recent activity (Feb 11, 2026) was a routine Go directive update to 1.25.0 — no new user-facing APIs were added. The module API has been stable for years.Available APIs (not yet used)
GetSize(fd int)ReadPassword(fd int)MakeRaw(fd int)Restore(fd int, state)NewTerminal(rw, prompt)Best Practices
golang.org/x/termin an internal package (as this project does ininternal/tty) is the recommended approach — it prevents the dependency from spreading throughout the codebase and makes it easy to mock/test.int(os.Stderr.Fd())cast pattern is idiomatic and correct.Improvement Opportunities
🏃 Quick Wins
Remove dead code:
IsStdoutTerminal()IsStdoutTerminal()ininternal/tty/tty.go(line 13) is never called anywhere in the project.Simplify
containsAnytest helper incontainer_test.gocontainsAnyhelper (lines 313–325) reimplements substring search with a manual nested loop:strings.Containsfrom the standard library, which is simpler, more readable, and better optimized:✨ Feature Opportunities
Terminal width-aware log output
term.GetSize(int(os.Stderr.Fd()))could be used in the logger to adapt log line width to the terminal width.Password/secret prompting at startup
term.ReadPassword()is already available via the existing dependency at zero extra cost.📐 Best Practice Alignment
internal/ttyis correct and idiomaticint(os.Fd())cast pattern is standardIsStdoutTerminal()exported but unused — either use it or remove itcontainsAnyshould usestrings.Contains🔧 General Improvements
The
internal/ttypackage currently mixes two concerns: terminal detection (tty.go) and container detection (container.go). These could eventually be split into separate focused packages (internal/ttyandinternal/container), but this is low priority since the package is small.Recommendations
IsStdoutTerminal()— dead exported code is confusingcontainsAnymanual loop withstrings.Contains— simpler and more standardterm.GetSize()for terminal-width-aware formatting in the loggerNext Steps
IsStdoutTerminal()should be removed or used somewhere (e.g., in a future stdout color detection path)containsAnytest helper to usestrings.ContainsGenerated by Go Fan 🐹
Module summary saved to:
/tmp/gh-aw/agent/term-module-summary.md(workspace write permission not available for specs/mods/)Run: §22476915418
**Ref...
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.