Add FORCE_COLOR environment variable support
Fixes #155
Adds support for the [`FORCE_COLOR`](https://force-color.org) environment variable. When `FORCE_COLOR` is set to any value other than `"0"`, colors are enabled regardless of TTY detection. `NO_COLOR` takes precedence over `FORCE_COLOR`.
This is useful for CI systems like GitHub Actions and GitLab CI that support ANSI colors but aren't detected as TTYs. The `FORCE_COLOR` convention has been standardized at https://force-color.org and is already widely supported in the Node.js ecosystem (chalk, etc.) and increasingly in other languages.
### Changes
- `color.go`: Added `forceColorIsSet()` helper and integrated it into the `NoColor` global initialization and `New()` constructor
- `color_test.go`: Added tests for `forceColorIsSet()`, color output with `FORCE_COLOR`, and `NO_COLOR` precedence over `FORCE_COLOR`
- `README.md`: Documented `FORCE_COLOR` support and updated the GitHub Actions section
### Testing
```
$ go test ./... -v
--- PASS: Test_forceColorIsSet (0.00s)
--- PASS: Test_forceColorIsSet/default (0.00s)
--- PASS: Test_forceColorIsSet/FORCE_COLOR=1 (0.00s)
--- PASS: Test_forceColorIsSet/FORCE_COLOR=0 (0.00s)
--- PASS: Test_forceColorIsSet/FORCE_COLOR=true (0.00s)
--- PASS: Test_forceColorIsSet/FORCE_COLOR= (0.00s)
--- PASS: TestForceColor (0.00s)
--- PASS: TestForceColorOverriddenByNoColor (0.00s)
PASS
ok github.com/fatih/color 0.239s
```
合并状态:未合并 3 条评论