Skip to content

Reduce internal tty API surface to the only production-used helper#6942

Merged
lpcox merged 2 commits into
mainfrom
copilot/go-fanmodule-review-golang-org-x-term
Jun 3, 2026
Merged

Reduce internal tty API surface to the only production-used helper#6942
lpcox merged 2 commits into
mainfrom
copilot/go-fanmodule-review-golang-org-x-term

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 3, 2026

The golang.org/x/term review found that internal/tty exposed two helpers with no production callers: IsStdoutTerminal and StderrTerminalWidth. This change trims the package to the single stderr TTY check actually used by the logger and aligns tests with that smaller surface.

  • API cleanup

    • Remove unused internal/tty helpers:
      • IsStdoutTerminal()
      • StderrTerminalWidth()
    • Keep IsStderrTerminal() as the only exported helper in the package.
  • Test realignment

    • Drop tests that existed only to cover the removed helpers.
    • Replace direct golang.org/x/term assertions in internal/tty tests with a package-level behavior test that swaps os.Stderr to a pipe and verifies it is not treated as a terminal.
  • Result

    • internal/tty now reflects actual usage in the codebase instead of carrying uncalled wrapper APIs.
// remaining package surface
func IsStderrTerminal() bool {
	return term.IsTerminal(int(os.Stderr.Fd()))
}

Copilot AI linked an issue Jun 3, 2026 that may be closed by this pull request
4 tasks
Copilot AI changed the title [WIP] Review Go module golang.org/x/term Reduce internal tty API surface to the only production-used helper Jun 3, 2026
Copilot finished work on behalf of lpcox June 3, 2026 13:58
Copilot AI requested a review from lpcox June 3, 2026 13:58
@lpcox lpcox marked this pull request as ready for review June 3, 2026 14:49
Copilot AI review requested due to automatic review settings June 3, 2026 14:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR trims the internal/tty package down to the single exported helper that is actually used in production (IsStderrTerminal), removing unused wrapper APIs and updating the unit tests to validate behavior via a pipe-backed os.Stderr.

Changes:

  • Removed unused exported helpers from internal/tty: IsStdoutTerminal() and StderrTerminalWidth().
  • Simplified internal/tty package documentation to match the reduced surface.
  • Updated internal/tty tests to validate IsStderrTerminal() behavior by swapping os.Stderr to a pipe, and dropped tests that only existed for the removed helpers.
Show a summary per file
File Description
internal/tty/tty.go Removes unused exported helpers, leaving only IsStderrTerminal() as the package API.
internal/tty/tty_test.go Removes tests tied to deleted helpers and adds a pipe-backed stderr behavior test for IsStderrTerminal().

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 87964ac into main Jun 3, 2026
35 checks passed
@lpcox lpcox deleted the copilot/go-fanmodule-review-golang-org-x-term branch June 3, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go-fan] Go Module Review: golang.org/x/term

3 participants