go install go101.org/gotv@latest
gotv
without any arguments to show help messages.
gotv
commands are in the following format:
gotv ToolchainVersion [go-arguments...]
ToolchainVersion
might be
1.17.13
, 1.18
, 1.19rc1
, which mean the release tags go1.17.13
, go1.18
, go1.19rc1
, respectively, in the Go git repository. Note:
1.N.
means the latest release of 1.N
(since Go toolchain 1.21, 1.N
also means the latest release of 1.N
).
1.
means the latest Go 1 release version.
.
means the latest Go release version.
:1.N
, which means the local latest release-branch.go1.N
branch in the Go git repository.
:tip
, which means the local latest master
branch in the Go git repository.
!
means to fetch remote versions (by running gotv fetch-versions
) firstly.
$ gotv 1.17. version [Run]: $HOME/.cache/gotv/tag_go1.17.13/bin/go version go version go1.17.13 linux/amd64 $ gotv 1.18.3 version [Run]: $HOME/.cache/gotv/tag_go1.18.3/bin/go version go version go1.18.3 linux/amd64 $ cat search.go package main import "fmt" func demoFilter(n int) bool { return n & 1 == 0; } // Search values and return them without perverting order. func search(start, end int)(r []int) { var count = 0 for i, index := start, 0; i <= end; i++ { if demoFilter(i) { count++ defer func(value int) { r[index] = value index++ }(i) } } r = make([]int, count) // only allocate once return } func main() { fmt.Println(search(0, 9)) } $ gotv 1.21 run search.go [Run]: $HOME/.cache/gotv/tag_go1.21.7/bin/go run search.go [8 6 4 2 0] $ gotv 1.22 run search.go [Run]: $HOME/.cache/gotv/tag_go1.22.1/bin/go run search.go [0 0 0 0 0]
gotv
specific commands:
# sync the local Go git repository with remote gotv fetch-versions # list all versions seen locally gotv list-versions # build and cache some toolchain versions gotv cache-version ToolchainVersion [ToolchainVersion ...] # uncache some toolchain versions to save disk space gotv uncache-version ToolchainVersion [ToolchainVersion ...] # pin a specified toolchain version at a stable path gotv pin-version ToolchainVersion # unpin the current pinned toolchain version gotv unpin-version # set the default toolchain version (since v0.2.1) gotv default-version ToolchainVersion # check the default toolchain version (since v0.2.1) gotv default-version
gotv pin-version
command to pin a specific toolchain version to a stable path. After adding the stable path to the PATH
environment veriable, we can use the official go
command directly. And after doing these, the toolchain versions installed through ways other than GoTV may be safely uninstalled.
$ gotv pin-version 1.17. [Run]: cp -r $HOME/.cache/gotv/tag_go1.17.13 $HOME/.cache/gotv/pinned-toolchain Please put the following shown pinned toolchain path in your PATH environment variable to use go commands directly: /home/username/.cache/gotv/pinned-toolchain/bin
$ go version go version go1.17.13 linux/amd64
gotv pin-version .!
will upgrade the pinned toolchain to the latest release version (which may be a beta or rc version).
PATH
environment variable as the bootstrap version by default. If GOROOT_BOOTSTRAP
environment variable is set, then its value will be used.
The Go 101 project is hosted on Github. Welcome to improve Go 101 articles by submitting corrections for all kinds of mistakes, such as typos, grammar errors, wording inaccuracies, description flaws, code bugs and broken links.
If you would like to learn some Go details and facts every serveral days, please follow Go 101's official Twitter account @zigo_101.