33## Branch Structure
44
55### Active Branches
6+
67- ** ` main ` ** - Active development for v3.x (Go rewrite) - ** USE THIS FOR ALL PRS**
78- ** ` master ` ** - Legacy v2.x maintenance only (bash-based)
89
910### PR Guidelines
11+
1012✅ Target ` main ` for: features, bug fixes, docs, improvements
1113❌ Target ` master ` only for: critical v2.x security patches
1214
1315### Branch Naming
16+
1417- ` fix/issue/NNN ` - Bug fixes
15- - ` feature/description ` - New features
18+ - ` feature/description ` - New features
1619- ` docs/description ` - Documentation
1720- ` refactor/description ` - Code refactoring
1821
1922## Project Architecture
2023
2124### Tech Stack
25+
2226- Language: Go (100% rewritten from bash in v3.x)
2327- CLI Framework: Cobra
2428- Testing: Go testing + some legacy BATS
2529
2630### Directory Structure
31+
2732```
2833cmd/ # CLI commands (Cobra-based)
2934├── core/ # Version management (install, use, list, info)
@@ -57,6 +62,7 @@ Windows uses `.bat` files instead of bash scripts for shims.
5762** Batch File Constraints** (Reference: Issue #555 ):
5863
5964❌ ** NEVER DO** :
65+
6066``` bat
6167# BAD - Breaks CMD parsing!
6268if "%var%"=="value" (
@@ -69,6 +75,7 @@ for %%a in (%*) do (...)
6975```
7076
7177✅ ** ALWAYS DO** :
78+
7279``` bat
7380# GOOD - Use subroutines
7481if "%var%"=="value" call :subroutine
@@ -80,21 +87,24 @@ exit /b 0
8087```
8188
8289** Key Rules** :
90+
83911 . NO goto/labels inside parenthesized ` if (...) ` blocks
84- 2 . NO raw ` %* ` expansion in ` for ` loops
92+ 2 . NO raw ` %* ` expansion in ` for ` loops
85933 . Use single-line conditionals when possible: ` if "%DEBUG%"=="1" echo on `
86944 . Always propagate exit codes: ` exit /b %ERRORLEVEL% `
87955 . Use subroutines with ` call :label ` for complex logic
8896
8997** Testing on macOS/Linux** :
98+
9099- Go tests validate template logic ✅
91100- Cannot execute ` .bat ` files on Unix
92101- CI runs Windows tests automatically
93102
94103## Key Implementation Patterns
95104
96105### Shim System Flow
97- 1 . User runs ` go version `
106+
107+ 1 . User runs ` go version `
981082 . Hits shim at ` ~/.goenv/shims/go ` (or ` go.bat ` on Windows)
991093 . Shim executes ` goenv exec go version `
1001104 . ` goenv exec ` resolves current version from:
@@ -106,12 +116,14 @@ exit /b 0
1061165 . Executes actual Go binary from resolved version
107117
108118### Shim Generation
119+
109120- Triggered by ` goenv rehash `
110121- Auto-rehashes after ` goenv install ` and ` go install `
111122- Scans all versions for binaries
112123- Creates platform-specific wrapper (bash or .bat)
113124
114125### Version Resolution
126+
115127- ` internal/resolver/resolver.go ` - Core logic
116128- Smart precedence handling
117129- Walks directory tree for ` .go-version `
@@ -138,20 +150,23 @@ make build
138150## Common Development Tasks
139151
140152### Adding a New Command
153+
1411541 . Create in appropriate ` cmd/<category>/ ` directory
1421552 . Use Cobra framework pattern
1431563 . Add to parent command's ` init() `
1441574 . Write tests in ` <name>_test.go `
1451585 . Update documentation
146159
147160### Modifying Shim Templates
161+
1481621 . Edit ` internal/shims/manager.go `
1491632 . Update ` createUnixShim() ` OR ` createWindowsShim() `
1501643 . ⚠️ Windows changes require extra care - see constraints above
1511654 . Test: ` go test ./internal/shims/... ./cmd/shims/... `
1521665 . Consider Windows batch file gotchas
153167
154168### Adding Platform Support
169+
1551701 . Update ` internal/utils/ ` for OS detection
1561712 . Add platform-specific shim generator
1571723 . Update install scripts
@@ -160,20 +175,23 @@ make build
160175## Code Style
161176
162177### Conventional Commits
178+
163179```
164180feat(area): description
165- fix(area): description
181+ fix(area): description
166182docs(area): description
167183refactor(area): description
168184test(area): description
169185```
170186
171187### Error Handling
188+
172189- Use ` internal/errors ` package
173190- Provide context: ` errors.FailedTo("action", err) `
174191- User-friendly messages
175192
176193### Configuration
194+
177195- Respect environment variables (` GOENV_* ` )
178196- Use ` internal/config ` for paths
179197- Support ` GOENV_ROOT ` customization
@@ -214,6 +232,7 @@ GitHub Actions builds release binaries for all platforms.
214232## Issue Resolution Checklist
215233
216234When fixing issues:
235+
2172361 . ✅ Read issue thoroughly including comments
2182372 . ✅ Identify affected files/components
2192383 . ✅ Check for similar issues in issue tracker
@@ -227,6 +246,7 @@ When fixing issues:
227246## Windows-Specific Issue Patterns
228247
229248Common Windows issues to watch for:
249+
230250- Batch file syntax errors (goto/label problems)
231251- Path separators (use ` filepath.Join ` )
232252- Line endings (CRLF vs LF - see ` .gitattributes ` )
0 commit comments