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
Go already supports [installing multiple versions][1] simultaneously as separate binaries,
13
-
e.g. `go` (the main version) and `go1.18` (an additional version).
14
-
It works just fine when interacting with`go <command>` directly,
15
-
but could be inconvenient when the command is wrapped with something like `Makefile` or shell scripts.
16
-
The `goversion` tool attempts to solve this by symlinking `go1.X.Y` to `go`,
17
-
so any additional Go version could be used as if it was the main one.
12
+
Go supports [installing multiple versions][1] simultaneously as separate binaries,
13
+
such as `go` (the main version) and `go1.18` (an add-on version).
14
+
This works fine when using`go <command>` directly,
15
+
but can be inconvenient when the command is hardcoded in a `Makefile` or a shell script.
16
+
The `goversion` tool solves this by symlinking `go1.X.Y` to `go`,
17
+
so that an add-on version can be used as the main one.
18
18
19
19
```shell
20
20
> go version
21
-
go version go1.19 darwin/arm64
21
+
go version go1.20 darwin/arm64
22
22
23
23
> goversion use 1.18
24
24
1.18 is not installed. Looking for it on go.dev ...
@@ -31,112 +31,126 @@ go version go1.18 darwin/arm64
31
31
32
32
## 🚀 Features
33
33
34
-
* Use any additional Go version as the main one
35
-
* List installed Go versions (and, optionally, all available versions)
36
-
* Remove an installed Go version with a single command
37
-
38
-
## ✏️ Pre-requirements
39
-
40
-
`$GOBIN` (usually `$HOME/go/bin`) must be in your `$PATH` and it must take precedence over the location of the main Go binary (e.g. `/usr/local/go/bin` or `/opt/homebrew/bin`).
34
+
* Install and switch between multiple Go versions
35
+
* List installed Go versions (optionally, all available versions)
36
+
* Remove installed Go versions with a single command
41
37
42
38
## 📦 Install
43
39
44
-
### Go
40
+
First, add `$GOBIN` (usually `$HOME/go/bin`) to your `$PATH`.
41
+
Make sure it takes precedence over the location of the main `go` binary (e.g. `/usr/local/go/bin` or `/opt/homebrew/bin`).
42
+
43
+
Then install `goversion` with Go...
45
44
46
45
```shell
47
46
go install go-simpler.org/goversion@latest
48
47
```
49
48
50
-
### Manual
49
+
...or download a prebuilt binary from the [Releases][2] page.
51
50
52
-
Download a prebuilt binary from the [Releases][2] page.
53
-
54
-
## 📋 Commands
51
+
## 📋 Usage
55
52
56
53
### Use
57
54
58
-
Switches the current Go version (will be installed if not already exists).
55
+
Switches the current Go version (will be installed if not exists).
59
56
60
57
```shell
61
58
> goversion use 1.18
62
59
Switched to 1.18
63
60
```
64
61
65
-
As a special case, the `main` string can be provided to quickly switch to the main version.
62
+
The special [gotip][3] version can be used just like any other.
66
63
67
64
```shell
68
-
> goversion use main
69
-
Switched to 1.19 (main)
65
+
> goversion use tip
66
+
Switched to tip
70
67
```
71
68
72
-
The `gotip` version can be used just like any other.
69
+
To switch back to the main version, use the `main` string.
73
70
74
71
```shell
75
-
> goversion use tip
76
-
Switched to tip
72
+
> goversion use main
73
+
Switched to 1.20 (main)
77
74
```
78
75
79
-
To update it, first switch to a stable Go version and then run `gotip download`.
80
-
81
76
### List
82
77
83
78
Prints the list of installed Go versions.
84
79
The current version is marked with the `*` symbol.
85
80
86
81
```shell
87
82
> goversion ls
88
-
1.19 (main)
83
+
1.20 (main)
89
84
* 1.18
90
-
1.17
91
85
```
92
86
93
-
The `-a (-all)` flag can be provided to print available versions from `go.dev` as well.
87
+
The `-a (-all)` flag can be used to print also available versions from `go.dev`.
94
88
95
89
```shell
96
-
> goversion ls -a
97
-
1.19.4 (not installed)
98
-
1.19.3 (not installed)
99
-
# ...
100
-
1.19 (main)
90
+
> goversion ls -all
91
+
tip (not installed)
92
+
1.20.14 (not installed)
93
+
1.20.13 (not installed)
101
94
# ...
102
-
1.2.2 (not installed)
103
-
1 (not installed)
95
+
1.3rc1 (not installed)
96
+
1.2.2 (not installed)
97
+
1 (not installed)
104
98
```
105
99
106
-
The full list is quite long, to limit it the `-only=<prefix>` flag can be used.
100
+
The `-only=<prefix>` flag can be used to print only versions starting with the prefix.
107
101
108
102
```shell
109
-
> goversion ls -a -only=1.18
110
-
1.18.9 (not installed)
111
-
1.18.8 (not installed)
103
+
> goversion ls -all -only=1.18
104
+
1.18.10 (not installed)
105
+
1.18.9 (not installed)
106
+
1.18.8 (not installed)
112
107
# ...
113
-
* 1.18
114
-
# ...
115
-
1.18beta2 (not installed)
116
-
1.18beta1 (not installed)
108
+
1.18rc1 (not installed)
109
+
1.18beta2 (not installed)
110
+
1.18beta1 (not installed)
117
111
```
118
112
119
-
If the `-only=latest` combination is provided, `ls` prints only the latest patch for each minor version.
113
+
If the `-only=latest` combination is given, `ls` prints only the latest patch for each version.
120
114
121
115
```shell
122
-
> goversion ls -a -only=latest
123
-
1.19.5 (not installed)
124
-
1.18.10 (not installed)
125
-
# ...
126
-
1.10.8 (not installed)
116
+
> goversion ls -all -only=latest
117
+
tip (not installed)
118
+
1.20.14 (not installed)
119
+
1.19.13 (not installed)
127
120
# ...
128
-
1.2.2 (not installed)
129
-
1 (not installed)
121
+
1.3.3 (not installed)
122
+
1.2.2 (not installed)
123
+
1 (not installed)
130
124
```
131
125
132
126
### Remove
133
127
134
-
Removes the specified Go version (both the binary and the SDK).
128
+
Removes the specified Go version (both binary and SDK).
0 commit comments