color

Colorized terminal output for Go with ANSI escape codes, 24-bit RGB, and built-in Windows support.

Library
Go
vv1.19.0
8,004 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 44
Maintenance 20
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
73 /100 Good
Architecture 68
Code Quality 85
Innovation 78
Learning Curve 60

fatih/color is a lightweight Go library for producing colorized terminal output using ANSI SGR escape codes. It exposes a chainable Color type alongside a set of convenient helper functions (Red, Green, Cyan, and more) so developers can add colored text to CLI tools with minimal boilerplate, whether printing directly, wrapping an io.Writer, or embedding colored substrings inside larger formatted strings.

The package automatically detects whether stdout is a terminal and disables coloring for non-tty output, such as when piped to another program, and it also respects the NO_COLOR environment variable convention. It ships first-class Windows support via go-colorable and go-isatty, so the same code produces correct output across platforms without conditional logic in the caller.

What You Get

  • Standard, hi-intensity, and 24-bit RGB foreground/background color support via Color and RGB/BgRGB constructors
  • Drop-in helper functions like color.Red, color.Cyan, and their *String variants for zero-boilerplate colored output
  • Automatic terminal detection that disables coloring on non-tty output or when NO_COLOR is set
  • Cross-platform ANSI rendering on Windows via bundled go-colorable/go-isatty integration
  • Composable Print/Fprint/Sprint function families, including PrintFunc/SprintFunc factories, for reusing a color across a codebase

Common Use Cases

  • Highlighting warnings, errors, and success messages in CLI tool output
  • Building colored log and status lines for build tools and test runners
  • Embedding colored substrings inside larger formatted strings via SprintFunc
  • Respecting user preferences and CI environments by auto-disabling color for piped or NO_COLOR output

Under The Hood

Architecture

fatih/color is intentionally flat: nearly all logic lives in a single color.go file, with color_windows.go adding a platform-specific init() for Windows virtual-terminal support and doc.go carrying package-level documentation. The core abstraction is the Color struct, a small value holding a slice of SGR Attribute values plus an optional per-instance noColor override; New() constructs one, Add()/AddRGB()/AddBgRGB() extend its parameter list, and format()/unformat() render the accumulated attributes into ANSI escape sequences on demand. Every print path (Print, Fprint, Sprint and their formatted/line variants) funnels through this same wrap()/format() machinery, and package-level helpers like Red or CyanString reuse cached Color instances via a mutex-guarded colorsCache map rather than reconstructing them per call. There’s no dependency injection or layering to speak of — the whole package is one cohesive unit built around a single mutable struct, which suits its narrow scope.

Tech Stack

The module targets Go 1.25 and depends on exactly three packages: github.com/mattn/go-colorable and github.com/mattn/go-isatty for terminal detection and Windows-safe ANSI writing, and golang.org/x/sys for the Windows console-mode syscalls used in color_windows.go’s init(). There’s no build tooling beyond the standard go toolchain, no runtime framework, and no external service integration — it’s a pure, dependency-light library meant to be imported directly.

Code Quality

Testing lives in color_test.go, which exercises every named color constant against its expected escape sequence and also drives visual/manual-inspection tests by writing through a buffered io.Writer. CI (.github/workflows/go.yml) runs go test -race, go vet, staticcheck, a go mod tidy diff check, and a full go build — a solid quality bar for a library this size. Naming is consistent and exported symbols carry doc comments; there’s no generics or heavy type machinery, which keeps the code straightforward to audit.

API Design The public API favors convenience over ceremony: users reach for package-level helpers (color.Red, color.CyanString) for one-off output, or construct a reusable *Color via New() when mixing attributes or calling repeatedly. PrintFunc/SprintFunc/FprintFunc factories let callers turn a configured Color into a plain function matching fmt’s own Print/Sprint/Fprint signatures, so integrating colored output into existing code requires no restructuring. The tradeoff is a fairly large exported surface (dozens of String and Hi variants) generated by hand rather than derived from a smaller primitive, but each function is self-explanatory and documented, keeping the learning curve low despite the surface area.

Used by 29 apps in this directory

Go
93%
MIT

Plandex

AI Code Assistants

15,777

An open-source, terminal-based AI coding agent built for large tasks and real codebases — with its own version control for plans, a 2M-token effective context window, and self-hosted or cloud deployment.

View details
50
Repo Health
70
Technical
67
Dependency
Built with
Go 93%
Updated 1 years ago
Go
69%
MIT

PocketBase

Authentication · Databases · Ecommerce

61,570

Open Source realtime backend in 1 file — embedded SQLite, auth, file storage, and admin UI as a single Go binary.

View details
90
Repo Health
87
Technical
77
Dependency
Built with
Go 69%
JavaScript 24%
Updated 1 weeks ago
Go
90%
AGPL 3.0

Pyroscope

Developer Tools · Devops · Monitoring

11,703

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
92
Repo Health
89
Technical
65
Dependency
Built with
Go 90%
Updated 6 days ago
Go
40%
Apache 2.0

Rill

Analytics · Data Engineering

2,962

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
88
Repo Health
88
Technical
64
Dependency
Built with
Go 40%
TypeScript 38%
Svelte 21%
Updated 6 days ago
Go
100%
Apache 2.0

SpiceDB

Authentication · Databases · Security

7,169

An open source, Google Zanzibar-inspired authorization database that models permissions as relationships and evaluates fine-grained access checks at massive scale with single-digit millisecond latency.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Go 100%
Updated 1 weeks ago
Go
99%
MIT

temporal

Automation · Devops

23,948

Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.

View details
92
Repo Health
85
Technical
67
Dependency
Built with
Go 99%
Updated 6 days ago
Go
95%
Apache 2.0

TiDB

AI Development · Databases

40,672

AI-Native Distributed SQL Database for Agentic Workloads

View details
97
Repo Health
66
Technical
68
Dependency
Built with
Go 95%
Updated 1 weeks ago
Go
54%
AGPL 3.0

Uptrace

Devops · Monitoring

4,305

Unified open-source APM that collects OpenTelemetry traces, metrics, and logs into a single self-hosted platform backed by ClickHouse.

View details
71
Repo Health
70
Technical
65
Dependency
Built with
Go 54%
Vue 34%
Updated 1 weeks ago
Go
66%
AGPL 3.0

Vikunja

Project Management

5,833

Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.

View details
86
Repo Health
81
Technical
65
Dependency
Built with
Go 66%
TypeScript 24%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers