You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+35-6Lines changed: 35 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,38 @@
2
2
3
3
A Go library for command-line color output with 16/256/RGB color support, cross-platform compatibility, and HTML-like tag functionality.
4
4
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.**
6
7
7
8
## Working Effectively
8
9
9
10
### Bootstrap and Dependencies
11
+
10
12
-`go mod tidy` - Download and organize dependencies. Takes ~5 seconds on first run.
11
13
-`go mod download` - Pre-download dependencies if needed.
12
14
13
15
### Build Operations
16
+
14
17
-`go build ./...` - Build all packages. EXTREMELY FAST: ~0.04 seconds. NEVER needs timeout adjustment.
15
18
-`go build .` - Build main package only.
16
19
- No Makefile or special build scripts needed - standard Go tooling only.
17
20
18
21
### Testing and Validation
22
+
19
23
-`go test ./...` - Run all tests. Takes ~15 seconds verbose mode. Set timeout to 30 seconds minimum.
20
24
-`go test -coverprofile=profile.cov ./...` - Generate coverage report. Takes ~1-2 seconds. NEVER CANCEL.
21
25
-`go test -v ./...` - Verbose test output showing all test details.
22
26
-`go test -race ./...` - Run tests with race detection (longer execution time).
23
27
24
28
### Code Quality
29
+
25
30
-`go fmt ./...` - Format code (always run before committing).
26
31
-`go vet ./...` - Run Go static analysis.
27
32
- NO golangci-lint configuration exists - do not attempt to run golangci-lint.
28
33
- NO custom linting setup - use standard Go tools only.
29
34
30
35
### Running Examples
36
+
31
37
-`go run _examples/demo.go` - Basic color demonstration.
32
38
-`go run _examples/color_256.go` - 256-color palette demonstration.
33
39
-`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-
39
45
**ALWAYS run these validation steps after making changes:**
40
46
41
47
### Core Functionality Validation
48
+
42
49
1.**Basic Color Output**: `go run _examples/demo.go` - Verify basic color functions work.
43
50
2.**256-Color Support**: `go run _examples/color_256.go` - Verify extended color palette.
44
51
3.**RGB Color Support**: `go run _examples/color_rgb.go` - Verify true color functionality.
45
52
4.**Tag Processing**: `go run _examples/color_tag.go` - Verify HTML-like tag parsing.
46
53
47
54
### Environment Detection Testing
55
+
48
56
1.**Debug Mode**: `COLOR_DEBUG_MODE=on go run _examples/envcheck.go` - Verify color detection logic.
49
57
2.**Color Capability Detection**: Run examples in different terminal environments to test detection.
50
58
51
59
### Test Coverage Validation
60
+
52
61
1.**Run Full Test Suite**: `go test -v ./...` - Must pass all tests.
53
62
2.**Coverage Check**: `go test -coverprofile=profile.cov ./...` - Maintain >95% coverage.
54
63
3.**Race Detection**: `go test -race ./...` - Verify thread safety.
55
64
56
65
## Key Project Structure
57
66
58
67
### Core Library Files
68
+
59
69
-`color.go` - Main color API and basic colors
60
70
-`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
62
72
-`color_rgb.go` - RGB/true color (24-bit) support
63
73
-`color_tag.go` - HTML-like tag parsing and rendering
64
74
-`style.go` - Color styles and style combinations
65
75
-`utils.go` - Color detection and platform utilities
66
76
67
77
### Platform-Specific Code
78
+
68
79
-`detect_env.go` - Environment-based color detection
69
80
-`detect_nonwin.go` - Unix/Linux/macOS color detection
70
81
-`detect_windows.go` - Windows color detection
71
82
72
83
### Testing and Examples
84
+
73
85
-`*_test.go` - Comprehensive test files (97.7% coverage)
74
86
-`_examples/` - Rich set of demonstration programs
75
87
-`testdata/` - Test data files
76
88
-`colorp/` - Alternative printer interface sub-package
77
89
78
90
### Example Programs Location
91
+
79
92
```
80
93
_examples/
81
94
├── demo.go # Basic color demonstration
@@ -90,98 +103,114 @@ _examples/
90
103
## Common Development Tasks
91
104
92
105
### Adding New Color Functions
106
+
93
107
1. Add function to appropriate `color_*.go` file
94
108
2. Add corresponding test in `*_test.go` file
95
109
3.**ALWAYS test**: `go test ./... && go run _examples/demo.go`
96
110
4. Update documentation if adding public API
97
111
98
112
### Modifying Color Detection
113
+
99
114
1. Edit `detect_*.go` files for platform-specific logic
100
115
2.**ALWAYS test with debug mode**: `COLOR_DEBUG_MODE=on go run _examples/envcheck.go`
101
116
3. Test on different platforms if possible
102
117
4. Verify tests pass: `go test ./...`
103
118
104
119
### Adding HTML Tag Support
120
+
105
121
1. Modify `color_tag.go` for tag parsing logic
106
122
2. Add tests to `color_tag_test.go`
107
123
3.**ALWAYS validate**: `go run _examples/color_tag.go`
108
124
4. Test edge cases with malformed tags
109
125
110
126
### Performance Optimization
127
+
111
128
1. Run benchmarks: `go test -bench=. -benchmem`
112
129
2. Profile if needed: `go test -cpuprofile=cpu.prof -memprofile=mem.prof`
113
130
3.**ALWAYS verify functionality still works** after optimizations
-**Module tidy**: ~5 seconds on first run, <1 second thereafter
158
182
-**NEVER need extended timeouts for builds**
159
183
160
184
### Test Operations
185
+
161
186
-**Basic test run**: ~1-2 seconds
162
-
-**Verbose tests**: ~15 seconds
187
+
-**Verbose tests**: ~15 seconds
163
188
-**Coverage generation**: ~1-2 seconds
164
189
-**Race detection**: ~30 seconds
165
190
-**Set minimum 30-second timeout for test commands**
166
191
167
192
### Example Execution
193
+
168
194
-**All examples**: <1 second each
169
195
-**Debug mode examples**: 1-2 seconds
170
196
-**No long-running examples or demos**
171
197
172
198
## CI/CD Integration
173
199
174
200
### GitHub Actions Workflow
201
+
175
202
-**File**: `.github/workflows/go.yml`
176
203
-**Platforms**: Ubuntu, Windows, macOS
177
204
-**Go versions**: 1.18 through 1.24
178
205
-**Coverage**: Automatically uploaded to Coveralls
179
206
180
207
### Pre-commit Checklist
208
+
181
209
1.`go fmt ./...` - Format code
182
-
2.`go vet ./...` - Static analysis
210
+
2.`go vet ./...` - Static analysis
183
211
3.`go test ./...` - Run all tests
184
212
4.`go run _examples/demo.go` - Basic functionality check
185
213
5. Verify no new build warnings
186
214
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.
0 commit comments