{"id":28259522,"url":"https://github.com/droqsic/glint","last_synced_at":"2025-07-18T05:34:27.929Z","repository":{"id":293018359,"uuid":"982673794","full_name":"droqsic/glint","owner":"droqsic","description":"High-performance, zero-allocation terminal color detection for Go. Thread-safe and cross-platform with advanced caching for optimal performance.","archived":false,"fork":false,"pushed_at":"2025-05-23T07:45:59.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-23T09:05:47.473Z","etag":null,"topics":["cli","color","colors","console","cross-platform","cygwin","go","golang","msys2","terminal","thread-safe","tty","zero-allocation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/droqsic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-13T08:37:49.000Z","updated_at":"2025-05-23T07:46:02.000Z","dependencies_parsed_at":"2025-05-13T09:52:10.024Z","dependency_job_id":null,"html_url":"https://github.com/droqsic/glint","commit_stats":null,"previous_names":["droqsic/glint"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/droqsic/glint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droqsic%2Fglint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droqsic%2Fglint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droqsic%2Fglint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droqsic%2Fglint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/droqsic","download_url":"https://codeload.github.com/droqsic/glint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droqsic%2Fglint/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265705443,"owners_count":23814461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","color","colors","console","cross-platform","cygwin","go","golang","msys2","terminal","thread-safe","tty","zero-allocation"],"created_at":"2025-05-20T03:12:16.715Z","updated_at":"2025-07-18T05:34:27.922Z","avatar_url":"https://github.com/droqsic.png","language":"Go","readme":"# Glint\n\n\u003cdiv align=\"center\"\u003e\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/droqsic/glint.svg)](https://pkg.go.dev/github.com/droqsic/glint)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Go Workflow](https://github.com/droqsic/glint/actions/workflows/go.yml/badge.svg)](https://github.com/droqsic/glint/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/droqsic/glint?nocache=1)](https://goreportcard.com/report/github.com/droqsic/glint)\n[![Latest Release](https://img.shields.io/github/v/release/droqsic/glint)](https://github.com/droqsic/glint/releases)\n[![Go Version](https://img.shields.io/badge/Go-1.24-blue.svg)](https://golang.org/)\n\n\u003c/div\u003e\n\n**Glint** is a lightweight, cross-platform Go library for detecting and enabling terminal color support. It combines performance, accuracy, and simplicity — with benchmarks showing it's up to **1000x faster** than alternatives.\n\n## Features\n\n- ⚡ **High Performance**: Advanced caching makes repeated checks nearly instantaneous\n- 🌐 **Cross-Platform**: Works on Windows, macOS, Linux, BSD, and more\n- 🧠 **Zero Allocations**: Efficient design ensures no heap allocations\n- 🔒 **Thread-Safe**: Safe for concurrent use from multiple goroutines\n- 🧼 **Simple API**: Easy to use and integrate\n- 📦 **Minimal Dependencies**: Only depends on the Go standard library, `x/sys`, and `probe`\n\n## Installation\n\n```bash\ngo get github.com/droqsic/glint\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/droqsic/glint\"\n)\n\nfunc main() {\n\t// Check if terminal supports colors\n\tfmt.Println(\"Terminal supports colors:\", glint.ColorSupport())\n\n\t// Get color support level\n\tfmt.Println(\"Color support level:\", glint.ColorLevel())\n\n\t// Force color support\n\tglint.ForceColor(true)\n\n    // Reset color support\n\tglint.ResetColor()\n}\n```\n\n## How It Works\n\nGlint determines terminal color support through:\n\n- 🧾 **Environment Variables**: Inspects `TERM`, `COLORTERM`, `NO_COLOR`\n- 🧪 **Terminal Detection**: Uses the `probe` library to check if output is a terminal\n- 🪟 **Windows Support**: Enables virtual terminal sequences when necessary\n- 🌈 **Color Levels**: Distinguishes between None, 16, 256, and True Color\n\nAll results are cached to ensure ultra-fast subsequent checks.\n\n## Performance\n\nGlint is engineered for speed. Here's what benchmarks reveal:\n\n```\nBenchmarkIsColorSupported-12                1000000000\t         0.25 ns/op\nBenchmarkIsColorSupportedLevel-12           1000000000\t         0.89 ns/op\nBenchmarkForceColorSupport-12               42567984\t        30.15 ns/op\n```\n\n- 🔁 **Cached Checks**: Almost all operations complete in under 1 ns\n- 🪄 **Zero Allocations**: No memory allocations for any operation\n- 💯 **High Throughput**: Ideal for performance-critical CLI tools\n\n## Color Support Levels\n\nGlint can detect four levels of color support:\n\n| Level       | Colors          | Example Terminals                               |\n| ----------- | --------------- | ----------------------------------------------- |\n| `LevelNone` | 0               | Non-interactive shells, logs                    |\n| `Level16`   | 16 ANSI colors  | `xterm`, `vt100`, `screen`                      |\n| `Level256`  | 256 colors      | `xterm-256color`, `screen-256color`             |\n| `LevelTrue` | 16M true colors | Terminals with `COLORTERM=truecolor` or `24bit` |\n\n## Thread Safety\n\nGlint is built with concurrency in mind. It uses synchronization mechanisms such as `sync.Once` and `sync.RWMutex` to manage its internal cache, allowing multiple goroutines to access color support checks safely and efficiently. The design is optimized for read-heavy workloads, ensuring high throughput and low latency even under concurrent access. This makes Glint well-suited for use in modern, parallelized Go applications.\n\n## Contributing\n\nWe welcome contributions of all kinds! Bug fixes, new features, test improvements, and docs are all appreciated.\n\n- Read the [Contributing Guide](docs/CONTRIBUTING.md) to get started\n- Please follow the [Code of Conduct](docs/CODE_OF_CONDUCT.md)\n\n## License\n\nGlint is released under the MIT License. For the full license text, please see the [LICENSE](LICENSE) file.\n\n## Acknowledgements\n\nThis project is inspired by the need for high-performance terminal color detection in real-world Go applications. Special thanks to:\n\n- The Go team for their exceptional language and tooling\n- The maintainers of x/sys for low-level system access\n- The creators of [Probe](https://github.com/droqsic/probe) for the terminal detection library\n- All contributors who help make Glint better\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroqsic%2Fglint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdroqsic%2Fglint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroqsic%2Fglint/lists"}