Replaces: fatih/color (26,630 importers, 7k+ stars, archived Oct 2024, author on indefinite sabbatical)
Package: github.com/agentine/tint
Language: Go
Why: fatih/color is the most widely used terminal color package in Go (26,630 importers). The author archived all his open source projects in mid-2024 and released a final v1.18.0 in October 2024 before stepping away indefinitely. The gofrs community discussed adopting it but declined. No maintained fork exists. Issues continue to be filed (as recently as Oct 2025) with no response. The package depends on mattn/go-colorable and mattn/go-isatty (still maintained but single-maintainer packages). A zero-dependency replacement with API compatibility eliminates the dependency chain risk entirely.
- Drop-in compatible with fatih/color API
- Zero dependencies — built-in isatty detection and Windows color support
- Extended color support — 256-color and RGB/true-color (24-bit) in addition to basic 16 colors
- Thread-safe — safe for concurrent use
- Modern Go — requires Go 1.21+, uses generics where beneficial
tint/
├── tint.go # Core Color type, attributes, Sprint/Fprint/Println API
├── attributes.go # Color attribute constants (FgRed, Bold, etc.)
├── writer.go # ColorableWriter for Windows ANSI translation
├── isatty.go # TTY detection (unix)
├── isatty_windows.go # TTY detection (windows)
├── colorable_windows.go # Windows console API color translation
├── colorable_other.go # No-op on Unix (ANSI native)
├── hicolor.go # 256-color and RGB/true-color support
├── global.go # Package-level convenience functions (Red, Blue, etc.)
├── compat/
│ └── color/ # Drop-in fatih/color replacement package
│ └── color.go # Re-exports with identical API surface
└── doc.go # Package documentation
type Color struct {
params []Attribute
noColor *bool // per-instance override
}
func New(attrs ...Attribute) *Color
func (c *Color) Add(attrs ...Attribute) *Color
func (c *Color) Sprint(a ...interface{}) string
func (c *Color) Sprintf(format string, a ...interface{}) string
func (c *Color) Sprintln(a ...interface{}) string
func (c *Color) Print(a ...interface{}) (int, error)
func (c *Color) Printf(format string, a ...interface{}) (int, error)
func (c *Color) Println(a ...interface{}) (int, error)
func (c *Color) Fprint(w io.Writer, a ...interface{}) (int, error)
func (c *Color) Fprintf(w io.Writer, format string, a ...interface{}) (int, error)
func (c *Color) Fprintln(w io.Writer, a ...interface{}) (int, error)
func (c *Color) SprintFunc() func(a ...interface{}) string
func (c *Color) SprintfFunc() func(format string, a ...interface{}) string
func (c *Color) PrintlnFunc() func(a ...interface{})
func (c *Color) Set() *Color // Set terminal color
func (c *Color) Unset() // Reset terminal color
func (c *Color) DisableColor()
func (c *Color) EnableColor()Standard 16-color ANSI attributes:
- Reset, Bold, Faint, Italic, Underline, BlinkSlow, BlinkRapid, ReverseVideo, Concealed, CrossedOut
- FgBlack, FgRed, FgGreen, FgYellow, FgBlue, FgMagenta, FgCyan, FgWhite
- FgHiBlack, FgHiRed, FgHiGreen, FgHiYellow, FgHiBlue, FgHiMagenta, FgHiCyan, FgHiWhite
- BgBlack, BgRed, ..., BgHiWhite
func Fg256(code uint8) Attribute // 256-color foreground
func Bg256(code uint8) Attribute // 256-color background
func FgRGB(r, g, b uint8) Attribute // True-color foreground
func BgRGB(r, g, b uint8) Attribute // True-color backgroundfunc Black(format string, a ...interface{}) { ... }
func Red(format string, a ...interface{}) { ... }
func Green(format string, a ...interface{}) { ... }
// ... etc for all 16 colors
func BlackString(format string, a ...interface{}) string { ... }
func RedString(format string, a ...interface{}) string { ... }
// ... etcvar NoColor = os.Getenv("NO_COLOR") != "" || os.Getenv("TERM") == "dumb"
var Output io.Writer = colorable.NewColorableStdout()
var Error io.Writer = colorable.NewColorableStderr()
func Unset() // Reset terminal colorsPlatform-specific TTY detection without external dependencies:
- Unix:
syscall.SYS_IOCTLwithTIOCGWINSZ - Windows:
GetConsoleModevia syscall - Plan9: check
/dev/cons
Translates ANSI escape sequences to Windows Console API calls:
- Parse ANSI SGR sequences from output stream
- Map to
SetConsoleTextAttributecalls - Support for 16-color, 256-color, and true-color (Windows 10+)
- Pass-through on terminals that support ANSI natively (Windows Terminal, WSL)
tint/compat/color provides 100% fatih/color API compatibility:
- Same type names, function signatures, constants
- Import path swap:
github.com/fatih/color→github.com/agentine/tint/compat/color - No behavior changes for existing code
- Core
tintpackage with full Color API - Built-in isatty detection (zero deps)
- Built-in Windows colorable writer (zero deps)
- 256-color and RGB/true-color extensions
tint/compat/colordrop-in compatibility package- Comprehensive test suite with platform-specific tests
- Benchmarks comparing to fatih/color
- README with migration guide
- GUI/rich-text rendering
- Image/pixel color manipulation
- Complex layout or box drawing (that's a TUI framework concern)