Commit 87964ac
authored
Reduce internal tty API surface to the only production-used helper (#6942)
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.
```go
// remaining package surface
func IsStderrTerminal() bool {
return term.IsTerminal(int(os.Stderr.Fd()))
}
```2 files changed
Lines changed: 11 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 11 | | |
21 | 12 | | |
22 | 13 | | |
| |||
35 | 26 | | |
36 | 27 | | |
37 | 28 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
50 | 32 | | |
51 | 33 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
81 | 42 | | |
0 commit comments