簡單的GO版本管理器,無麩質。

現有版本管理器從源構建,具有太多的依賴關係,污染路徑和/或要求您使用特定的外殼環境。 g目標是盡可能不引人注目和便攜。
g的靈感來自TJ/N-我過去為此做出了貢獻 - 並藉用了一些代碼。
$GOPATH和$GOROOT都出口了什麼,無論...go ,而不是g 。source函數。curl和wget頭等艙支持。curl或wget ,分別使用curl -V或wget -V檢查。絕對不必要,但強烈建議完全刪除任何先前的GO安裝 - 只是為了防止任何奇怪的結果。
重要的是:在您繼續之前,我鼓勵您閱讀安裝腳本;永遠不要相信有人告訴您運行隨機命令。
也就是說,您可以使用一個命令安裝g :
curl -sSL https://git.io/g-install | sh -s如果您改用wget :
wget -qO- https://git.io/g-install | sh -s這將下載g腳本,將其放入$GOPATH/bin/ ,使用chmod賦予其執行權,並配置默認的Shell的初始化文件,將GOPATH & GOROOT環境變量設置並在PATH中添加$GOPATH/bin 。
然後,您將提示安裝最新版本的GO;您可以跳過此步驟,並在稍後使用g安裝首選版本。
注意:您必須重新啟動當前的外殼會話才能讀取這些新的env vars,以便使用g或go 。
當前,安裝腳本支持以下外殼:
這並不意味著您不能將g與其他外殼一起使用,只需進行手動安裝即可。
安裝腳本將選擇您的默認外殼進行配置。您可能會通過運行看到您的默認外殼是什麼:
echo $SHELL如果您想配置diff shell,則可以將其作為參數傳遞:
curl -sSL https://git.io/g-install | sh -s -- fish您不妨配置多個外殼,但這通常不需要:
curl -sSL https://git.io/g-install | sh -s -- fish bash zsh
使用-y選項跳過提示,並為所有內容假設“是”:
curl -sSL https://git.io/g-install | sh -s -- -y默認情況下,使用了這些GO環境變量:
GOROOT: $HOME/.go
GOPATH: $HOME/go
$GOPATH/bin被添加到PATH中,在某些地方被複製g 。
您可以在運行安裝腳本之前設置這些變量。例如,在Bash和Zsh中:
export GOROOT= ~ /.local/share/golang
export GOPATH= ~ /MyProjects/go-projects
curl -sSL https://git.io/g-install | sh -s在魚中:
set -gx GOROOT ~ /.local/share/golang
set -gx GOPATH ~ /MyProjects/go-projects
curl -sSL https://git.io/g-install | sh -s$GOPATH和$GOROOT環境變量,然後在您的PATH中添加$GOPATH/bin 。./bin/g腳本的副本,然後將其放在PATH中的任何地方 - 內部$GOPATH/bin/是一個不錯的選擇。chmod +x $GOPATH/bin/g提供腳本執行權。g包括一個self-upgrade命令,您可以運行以獲取最新版本的g此命令只需再次運行安裝腳本即可。
Usage: g [COMMAND] [options] [args]
Commands:
g Open interactive UI with downloaded versions
g install latest Download and set the latest go release
g install <version> Download and set go <version>
g download <version> Download go <version>
g set <version> Switch to go <version>
g run <version> Run a given version of go
g which <version> Output bin path for <version>
g remove <version ...> Remove the given version(s)
g prune Remove all versions except the current version
g list Output downloaded go versions
g list-all Output all available, remote go versions
g self-upgrade Upgrades g to the latest version
g help Display help information, same as g --help
Options:
-h, --help Display help information and exit
-v, --version Output current version of g and exit
-q, --quiet Suppress almost all output
-c, --no-color Force disabled color output
-y, --non-interactive Prevent prompts
-o, --os Override operating system
-a, --arch Override system architecture
-u, --unstable Include unstable versions in list
g是一個可移植的外殼腳本,就像$PATH中可用的二進製文件一樣。如果您使用安裝腳本設置g ,則其刪除應該非常直截了當。
首先,獲取有關您系統的一些信息:
echo $SHELL
echo $GOROOT
echo $GOPATH
command -v g您會注意到g文件屬於$GOPATH/bin/ directory。如果您只想刪除g並保留當前安裝的go二進製文件和相關文件,只需刪除g :
# If you're using bash, zsh, or other POSIX shell:
rm " $( command -v g ) "
# If you're using fish:
rm (command -v g)現在,如果您想刪除所有內容,請首先確保在$GOROOT內部備份您的項目(如果有)。然後刪除$GOROOT和$GOPATH中的所有內容:
rm -r $GOPATH $GOROOT然後,使用您選擇的文本編輯器打開shell配置文件,並查找包含g-install以刪除其的行。這些是安裝腳本通常使用的位置:
# bash on MacOS
~ /.bash_profile
# bash on linux/BSD
~ /.bashrc
# zsh
~ /.zshrc
# fish shell
~ /.config/fish/config.fish
# csh
~ /.cshrc
# tcsh
~ /.tcshrc
# For ash and dash, check your $ENV var
echo $ENV在這一點上,您將刪除g並完全go 。
g和g-install Posix符合POSIX g-install時已經有Golang安裝g install <version> ,也許use或set 。參見#8 install進行安裝和刪除--download選項g時處理案例,主要是zsh與oh-my-zsh g-install為用戶提供的設置g的替代別名self-upgrade安裝g complete命令,該命令為受支持的外殼生成完整g-install設置外殼以調用此命令以完成g )goenv 。gvm幾乎相同。請閱讀貢獻。 ♥
n項目, g是受和基於基礎的啟發。n-install項目, g也基於該項目。 麻省理工學院♥