|
| 1 | +# Migration Guide: goenv v2 to v3 |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +goenv v3 is fully backward compatible with v2. Most users can migrate immediately without any changes to their workflows or scripts. |
| 6 | + |
| 7 | +## Key Changes |
| 8 | + |
| 9 | +### Architecture |
| 10 | +- **v2**: Shell script-based implementation |
| 11 | +- **v3**: Go-based CLI for improved performance and reliability |
| 12 | + |
| 13 | +### Compatibility |
| 14 | +✅ All v2 commands work identically in v3 |
| 15 | +✅ `.go-version` files are fully compatible |
| 16 | +✅ Environment variables (`GOENV_ROOT`, `GOPATH`, `GOROOT`) work the same |
| 17 | +✅ Plugin system remains compatible |
| 18 | +✅ Shell initialization (`goenv init`) unchanged |
| 19 | + |
| 20 | +## Migration Steps |
| 21 | + |
| 22 | +### For Individual Users |
| 23 | + |
| 24 | +1. **If using Homebrew:** |
| 25 | + ```bash |
| 26 | + # Upgrade to v3 |
| 27 | + brew upgrade goenv |
| 28 | + |
| 29 | + # Verify installation |
| 30 | + goenv --version |
| 31 | + ``` |
| 32 | + |
| 33 | +2. **If using Git installation:** |
| 34 | + ```bash |
| 35 | + cd ~/.goenv |
| 36 | + git fetch --all |
| 37 | + git checkout v3 |
| 38 | + |
| 39 | + # Restart your shell |
| 40 | + exec $SHELL |
| 41 | + |
| 42 | + # Verify installation |
| 43 | + goenv --version |
| 44 | + ``` |
| 45 | + |
| 46 | +3. **Test your setup:** |
| 47 | + ```bash |
| 48 | + # Check current version |
| 49 | + goenv version |
| 50 | + |
| 51 | + # List installed versions |
| 52 | + goenv versions |
| 53 | + |
| 54 | + # Install a new version (if needed) |
| 55 | + goenv install 1.21.0 |
| 56 | + ``` |
| 57 | + |
| 58 | +### For CI/CD Systems |
| 59 | + |
| 60 | +#### AWS CodeBuild |
| 61 | + |
| 62 | +Update your `buildspec.yml`: |
| 63 | + |
| 64 | +```yaml |
| 65 | +phases: |
| 66 | + pre_build: |
| 67 | + commands: |
| 68 | + - echo "Installing goenv v3..." |
| 69 | + - git clone https://github.com/go-nv/goenv.git ~/.goenv |
| 70 | + - export GOENV_ROOT="$HOME/.goenv" |
| 71 | + - export PATH="$GOENV_ROOT/bin:$PATH" |
| 72 | + - eval "$(goenv init -)" |
| 73 | + - goenv install 1.21.0 |
| 74 | + - goenv global 1.21.0 |
| 75 | + - go version |
| 76 | +``` |
| 77 | +
|
| 78 | +#### Docker Containers |
| 79 | +
|
| 80 | +Update your Dockerfile: |
| 81 | +
|
| 82 | +```dockerfile |
| 83 | +# Install goenv v3 |
| 84 | +RUN git clone https://github.com/go-nv/goenv.git /root/.goenv |
| 85 | +ENV GOENV_ROOT=/root/.goenv |
| 86 | +ENV PATH=$GOENV_ROOT/bin:$PATH |
| 87 | + |
| 88 | +# Initialize goenv |
| 89 | +RUN echo 'eval "$(goenv init -)"' >> /root/.bashrc |
| 90 | +RUN bash -c 'eval "$(goenv init -)" && goenv install 1.21.0 && goenv global 1.21.0' |
| 91 | +``` |
| 92 | + |
| 93 | +#### GitHub Actions |
| 94 | + |
| 95 | +```yaml |
| 96 | +- name: Setup goenv |
| 97 | + run: | |
| 98 | + git clone https://github.com/go-nv/goenv.git ~/.goenv |
| 99 | + echo "GOENV_ROOT=$HOME/.goenv" >> $GITHUB_ENV |
| 100 | + echo "$HOME/.goenv/bin" >> $GITHUB_PATH |
| 101 | + |
| 102 | +- name: Install Go via goenv |
| 103 | + run: | |
| 104 | + eval "$(goenv init -)" |
| 105 | + goenv install 1.21.0 |
| 106 | + goenv global 1.21.0 |
| 107 | +``` |
| 108 | +
|
| 109 | +## Staying on v2 |
| 110 | +
|
| 111 | +If you need to remain on v2 for validation purposes: |
| 112 | +
|
| 113 | +### Homebrew |
| 114 | +```bash |
| 115 | +brew install goenv@2 && brew link goenv@2 |
| 116 | +``` |
| 117 | + |
| 118 | +### Git |
| 119 | +```bash |
| 120 | +cd ~/.goenv |
| 121 | +git checkout master # v2 is maintained on master branch |
| 122 | +``` |
| 123 | + |
| 124 | +## Rollback to v2 |
| 125 | + |
| 126 | +If you encounter issues with v3: |
| 127 | + |
| 128 | +### Homebrew |
| 129 | +```bash |
| 130 | +brew unlink goenv # keeps install, but allows for switching |
| 131 | +brew install goenv@2 && brew link goenv@2 |
| 132 | +``` |
| 133 | + |
| 134 | +### Git |
| 135 | +```bash |
| 136 | +cd ~/.goenv |
| 137 | +git checkout master |
| 138 | +exec $SHELL |
| 139 | +``` |
| 140 | + |
| 141 | +## Support |
| 142 | + |
| 143 | +- **v3 Issues**: [GitHub Issues](https://github.com/go-nv/goenv/issues) |
| 144 | +- **v2 Support**: Maintained until April 2028 or End of Support |
| 145 | +- **Questions**: [GitHub Discussions](https://github.com/go-nv/goenv/discussions) |
| 146 | + |
| 147 | +## Breaking Changes |
| 148 | + |
| 149 | +There are **no breaking changes** between v2 and v3. All commands, flags, and behaviors remain consistent. |
| 150 | + |
| 151 | +## Performance Improvements |
| 152 | + |
| 153 | +v3 offers significant performance improvements over v2: |
| 154 | +- Faster command execution (Go vs shell scripts) |
| 155 | +- Reduced startup time |
| 156 | +- More efficient version switching |
| 157 | +- Improved error handling and messaging |
| 158 | + |
| 159 | +## Recommended Migration Timeline |
| 160 | + |
| 161 | +- **Immediate**: Individual developer machines |
| 162 | +- **1-2 weeks**: Development and staging environments |
| 163 | +- **1-2 months**: Production CI/CD pipelines (after validation) |
| 164 | +- **2-6 months**: Critical infrastructure with strict change control |
0 commit comments