Instale o script para go lang

0

Eu quero ter um script de trabalho para instalar.

Eu não sei como configurar as variáveis de ambiente. Eu usei

echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile

Eu reabri o terminal, mas não funcionou. Então eu

echo 'export GOROOT=/usr/local/go'
echo 'export PATH=$PATH:$GOROOT/bin'
echo 'export GOPATH=$HOME/code/go'
echo 'export PATH=$PATH:$GOPATH/bin'

e funcionou, mas nas instruções diz:

Note: GOROOT must be set only when installing to a custom location.

#!/bin/bash

# shellcheck disable=SC2034
declare -f assertConfirmation &>/dev/null ||  source "$HOME/.dotfiles/install/declarations"

goVersion="1.10"

if [ -d "$HOME/.go" ] || [ -d "$HOME/go" ] || [ -d "$HOME/code/go" ]; then
    echo "The 'go' directory already exists. Exiting."
    exit 1
fi

if [ -n "'$SHELL -c 'echo $ZSH_VERSION''" ]; then
    shell_profile="zshrc" # assume Zsh
elif [ -n "'$SHELL -c 'echo $BASH_VERSION''" ]; then
    shell_profile="bashrc" # assume Bash
fi

if [ "$ARCH" = "32" ];then localArch="386"; else localArch="amd64"; fi
[[ $OS == *"linux"* ]]  &&  localOS="linux"
DFILE="go$goVersion.$localOS-$localArch.tar.gz"
goURL="https://dl.google.com/go/$DFILE"

if [ ! -d /usr/local/go ]; then
    wget "$goURL" -O /tmp/go.tar.gz  ||  \
        { echo "Couldn't download go" ; exit ; }
    sudo tar -C /usr/local/ -zxvf /tmp/go.tar.gz
    rm -f /tmp/go.tar.gz
fi

if [ -f /etc/profile ]  &&  ! grep -q "/usr/local/go" /etc/profile; then
    echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile
fi
if ! grep -q "/usr/local/go" ~/.${shell_profile}; then
    mkdir -p ~/code/go
    {
        echo '# GoLang'
        echo 'export GOROOT=/usr/local/go'
        echo 'export PATH=$PATH:$GOROOT/bin'
        echo 'export GOPATH=$HOME/code/go'
        echo 'export PATH=$PATH:$GOPATH/bin'
    } >> ~/.${shell_profile}
fi
    
por arturo 27.03.2018 / 15:54

0 respostas