Skip to content

Commit c34c15e

Browse files
committed
🎨 doc: update readme and format the.github/copilot-instructions.md
1 parent 370e227 commit c34c15e

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

.github/copilot-instructions.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,38 @@
22

33
A Go library for command-line color output with 16/256/RGB color support, cross-platform compatibility, and HTML-like tag functionality.
44

5-
**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
5+
**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does
6+
not match the info here.**
67

78
## Working Effectively
89

910
### Bootstrap and Dependencies
11+
1012
- `go mod tidy` - Download and organize dependencies. Takes ~5 seconds on first run.
1113
- `go mod download` - Pre-download dependencies if needed.
1214

1315
### Build Operations
16+
1417
- `go build ./...` - Build all packages. EXTREMELY FAST: ~0.04 seconds. NEVER needs timeout adjustment.
1518
- `go build .` - Build main package only.
1619
- No Makefile or special build scripts needed - standard Go tooling only.
1720

1821
### Testing and Validation
22+
1923
- `go test ./...` - Run all tests. Takes ~15 seconds verbose mode. Set timeout to 30 seconds minimum.
2024
- `go test -coverprofile=profile.cov ./...` - Generate coverage report. Takes ~1-2 seconds. NEVER CANCEL.
2125
- `go test -v ./...` - Verbose test output showing all test details.
2226
- `go test -race ./...` - Run tests with race detection (longer execution time).
2327

2428
### Code Quality
29+
2530
- `go fmt ./...` - Format code (always run before committing).
2631
- `go vet ./...` - Run Go static analysis.
2732
- NO golangci-lint configuration exists - do not attempt to run golangci-lint.
2833
- NO custom linting setup - use standard Go tools only.
2934

3035
### Running Examples
36+
3137
- `go run _examples/demo.go` - Basic color demonstration.
3238
- `go run _examples/color_256.go` - 256-color palette demonstration.
3339
- `go run _examples/color_rgb.go` - RGB/true color demonstration.
@@ -39,43 +45,50 @@ A Go library for command-line color output with 16/256/RGB color support, cross-
3945
**ALWAYS run these validation steps after making changes:**
4046

4147
### Core Functionality Validation
48+
4249
1. **Basic Color Output**: `go run _examples/demo.go` - Verify basic color functions work.
4350
2. **256-Color Support**: `go run _examples/color_256.go` - Verify extended color palette.
4451
3. **RGB Color Support**: `go run _examples/color_rgb.go` - Verify true color functionality.
4552
4. **Tag Processing**: `go run _examples/color_tag.go` - Verify HTML-like tag parsing.
4653

4754
### Environment Detection Testing
55+
4856
1. **Debug Mode**: `COLOR_DEBUG_MODE=on go run _examples/envcheck.go` - Verify color detection logic.
4957
2. **Color Capability Detection**: Run examples in different terminal environments to test detection.
5058

5159
### Test Coverage Validation
60+
5261
1. **Run Full Test Suite**: `go test -v ./...` - Must pass all tests.
5362
2. **Coverage Check**: `go test -coverprofile=profile.cov ./...` - Maintain >95% coverage.
5463
3. **Race Detection**: `go test -race ./...` - Verify thread safety.
5564

5665
## Key Project Structure
5766

5867
### Core Library Files
68+
5969
- `color.go` - Main color API and basic colors
6070
- `color_16.go` - 16-color (4-bit) support
61-
- `color_256.go` - 256-color (8-bit) support
71+
- `color_256.go` - 256-color (8-bit) support
6272
- `color_rgb.go` - RGB/true color (24-bit) support
6373
- `color_tag.go` - HTML-like tag parsing and rendering
6474
- `style.go` - Color styles and style combinations
6575
- `utils.go` - Color detection and platform utilities
6676

6777
### Platform-Specific Code
78+
6879
- `detect_env.go` - Environment-based color detection
6980
- `detect_nonwin.go` - Unix/Linux/macOS color detection
7081
- `detect_windows.go` - Windows color detection
7182

7283
### Testing and Examples
84+
7385
- `*_test.go` - Comprehensive test files (97.7% coverage)
7486
- `_examples/` - Rich set of demonstration programs
7587
- `testdata/` - Test data files
7688
- `colorp/` - Alternative printer interface sub-package
7789

7890
### Example Programs Location
91+
7992
```
8093
_examples/
8194
├── demo.go # Basic color demonstration
@@ -90,98 +103,114 @@ _examples/
90103
## Common Development Tasks
91104

92105
### Adding New Color Functions
106+
93107
1. Add function to appropriate `color_*.go` file
94108
2. Add corresponding test in `*_test.go` file
95109
3. **ALWAYS test**: `go test ./... && go run _examples/demo.go`
96110
4. Update documentation if adding public API
97111

98112
### Modifying Color Detection
113+
99114
1. Edit `detect_*.go` files for platform-specific logic
100115
2. **ALWAYS test with debug mode**: `COLOR_DEBUG_MODE=on go run _examples/envcheck.go`
101116
3. Test on different platforms if possible
102117
4. Verify tests pass: `go test ./...`
103118

104119
### Adding HTML Tag Support
120+
105121
1. Modify `color_tag.go` for tag parsing logic
106122
2. Add tests to `color_tag_test.go`
107123
3. **ALWAYS validate**: `go run _examples/color_tag.go`
108124
4. Test edge cases with malformed tags
109125

110126
### Performance Optimization
127+
111128
1. Run benchmarks: `go test -bench=. -benchmem`
112129
2. Profile if needed: `go test -cpuprofile=cpu.prof -memprofile=mem.prof`
113130
3. **ALWAYS verify functionality still works** after optimizations
114131

115132
## Environment and Dependencies
116133

117134
### Go Version Requirements
135+
118136
- **Minimum**: Go 1.18
119137
- **Tested**: Go 1.18 through 1.24
120138
- Check version: `go version`
121139

122140
### Dependencies (go.mod)
141+
123142
- `github.com/stretchr/testify` - Testing framework
124143
- `github.com/xo/terminfo` - Terminal info library
125144
- `golang.org/x/sys` - System interfaces
126145
- **All dependencies are lightweight** - no complex setup required
127146

128147
### Platform Support
148+
129149
- **Linux**: Full support (16/256/RGB colors)
130-
- **macOS**: Full support (16/256/RGB colors)
150+
- **macOS**: Full support (16/256/RGB colors)
131151
- **Windows**: Full support including CMD and PowerShell
132152
- **WSL**: Supported with automatic detection
133153

134154
## Debugging and Troubleshooting
135155

136156
### Color Detection Issues
157+
137158
1. **Enable debug mode**: `COLOR_DEBUG_MODE=on`
138159
2. **Check environment**: `go run _examples/envcheck.go`
139160
3. **Verify TERM variable**: `echo $TERM`
140161
4. **Test in different terminals**: cmd, PowerShell, iTerm, etc.
141162

142163
### Test Failures
164+
143165
1. **Run verbose tests**: `go test -v ./...`
144166
2. **Check race conditions**: `go test -race ./...`
145167
3. **Verify environment**: Some tests are environment-dependent
146168
4. **Check platform-specific code**: Windows vs Unix behavior
147169

148170
### Build Issues
171+
149172
1. **Update dependencies**: `go mod tidy`
150173
2. **Clear module cache**: `go clean -modcache` (rarely needed)
151174
3. **Check Go version**: Must be 1.18+
152175

153176
## Timing Expectations
154177

155178
### Build Operations
179+
156180
- **Build time**: ~0.04 seconds (extremely fast)
157181
- **Module tidy**: ~5 seconds on first run, <1 second thereafter
158182
- **NEVER need extended timeouts for builds**
159183

160184
### Test Operations
185+
161186
- **Basic test run**: ~1-2 seconds
162-
- **Verbose tests**: ~15 seconds
187+
- **Verbose tests**: ~15 seconds
163188
- **Coverage generation**: ~1-2 seconds
164189
- **Race detection**: ~30 seconds
165190
- **Set minimum 30-second timeout for test commands**
166191

167192
### Example Execution
193+
168194
- **All examples**: <1 second each
169195
- **Debug mode examples**: 1-2 seconds
170196
- **No long-running examples or demos**
171197

172198
## CI/CD Integration
173199

174200
### GitHub Actions Workflow
201+
175202
- **File**: `.github/workflows/go.yml`
176203
- **Platforms**: Ubuntu, Windows, macOS
177204
- **Go versions**: 1.18 through 1.24
178205
- **Coverage**: Automatically uploaded to Coveralls
179206

180207
### Pre-commit Checklist
208+
181209
1. `go fmt ./...` - Format code
182-
2. `go vet ./...` - Static analysis
210+
2. `go vet ./...` - Static analysis
183211
3. `go test ./...` - Run all tests
184212
4. `go run _examples/demo.go` - Basic functionality check
185213
5. Verify no new build warnings
186214

187-
Remember: This is a mature, stable library with excellent test coverage. Most changes should be small and focused. Always validate color output works correctly across different terminal environments when making changes to color detection or rendering logic.
215+
Remember: This is a mature, stable library with excellent test coverage. Most changes should be small and focused. Always validate color
216+
output works correctly across different terminal environments when making changes to color detection or rendering logic.

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/color?style=flat-square)
44
[![Actions Status](https://github.com/gookit/color/workflows/action-tests/badge.svg)](https://github.com/gookit/color/actions)
55
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7fef8d74c1d64afc99ce0f2c6d3f8af1)](https://www.codacy.com/gh/gookit/color/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=gookit/color&amp;utm_campaign=Badge_Grade)
6-
[![GoDoc](https://godoc.org/github.com/gookit/color?status.svg)](https://pkg.go.dev/github.com/gookit/color?tab=overview)
6+
[![GoDoc](https://pkg.go.dev/badge/github.com/gookit/color.svg)](https://pkg.go.dev/github.com/gookit/color?tab=overview)
77
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/color)](https://github.com/gookit/color)
8-
[![Build Status](https://travis-ci.org/gookit/color.svg?branch=master)](https://travis-ci.org/gookit/color)
98
[![Coverage Status](https://coveralls.io/repos/github/gookit/color/badge.svg?branch=master)](https://coveralls.io/github/gookit/color?branch=master)
109
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/color)](https://goreportcard.com/report/github.com/gookit/color)
1110

@@ -41,8 +40,7 @@ Now, 256 colors and RGB colors have also been supported to work in Windows CMD a
4140

4241
## GoDoc
4342

44-
- [godoc for gopkg](https://pkg.go.dev/gopkg.in/gookit/color.v1)
45-
- [godoc for github](https://pkg.go.dev/github.com/gookit/color)
43+
See [godoc for github](https://pkg.go.dev/github.com/gookit/color)
4644

4745
## Install
4846

README.zh-CN.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/color?style=flat-square)
44
[![Actions Status](https://github.com/gookit/color/workflows/action-tests/badge.svg)](https://github.com/gookit/color/actions)
55
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/7fef8d74c1d64afc99ce0f2c6d3f8af1)](https://www.codacy.com/gh/gookit/color/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=gookit/color&amp;utm_campaign=Badge_Grade)
6-
[![GoDoc](https://godoc.org/github.com/gookit/color?status.svg)](https://pkg.go.dev/github.com/gookit/color?tab=overview)
6+
[![GoDoc](https://pkg.go.dev/badge/github.com/gookit/color.svg)](https://pkg.go.dev/github.com/gookit/color?tab=overview)
77
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/color)](https://github.com/gookit/color)
8-
[![Build Status](https://travis-ci.org/gookit/color.svg?branch=master)](https://travis-ci.org/gookit/color)
98
[![Coverage Status](https://coveralls.io/repos/github/gookit/color/badge.svg?branch=master)](https://coveralls.io/github/gookit/color?branch=master)
109
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/color)](https://goreportcard.com/report/github.com/gookit/color)
1110

@@ -41,8 +40,7 @@ Golang下的命令行色彩使用库, 拥有丰富的色彩(16/256/True)渲染
4140

4241
## GoDoc
4342

44-
- [godoc for gopkg](https://pkg.go.dev/gopkg.in/gookit/color.v1)
45-
- [godoc for github](https://pkg.go.dev/github.com/gookit/color)
43+
[godoc for github](https://pkg.go.dev/github.com/gookit/color)
4644

4745
## 安装
4846

0 commit comments

Comments
 (0)