Loading
chore(deps): replace mgutz/ansi with local SGR codes
Description
github.com/mgutz/ansi is unmaintained, and its only remaining use was the basic-ANSI fallback in makeColorFunc (internal/iostreams/color.go). This MR replaces that call with a small map from the eight palette names to their SGR parameters, then drops the dependency (go mod tidy). Nothing else in the module graph imports it.
- Output is byte-identical to what mgutz/ansi produced. I checked each name against the library directly, for example
default+bgives\x1b[0;1;39m…\x1b[0m. - Empty input still returns
"", as before. - An unknown name now returns the text unchanged. mgutz/ansi fell back to black (
0;30) in that case. All callers pass one of the eight fixed names, so this path never runs. - The issue suggests
termenv. I didn't use it here because the closed !3141 (closed) lost color under the pager:termenvprobess.StdOutfor a TTY, and under the pager that is a pipe. Writing the codes directly keeps the current TTY and color gating as it is. - I also removed the
// basic ANSI colorscomment, becausescripts/comment-overlapflags it against the new lookup line.
Note: !3955 also edits makeColorFunc and color_test.go. This diff stays small so that whichever MR merges second only has a small rebase.
Related Issues
Resolves #8270 (closed)
How has this been tested?
Test_makeColorFunc: the existing cases pass unchanged. I added table cases for magenta, cyan, red, yellow, blue,default+band an unknown name, plus a test for empty text.go test ./...passes.golangci-lint run ./internal/iostreams/...reports 0 issues.