Skip to content

Instantly share code, notes, and snippets.

@ndaidong
Last active June 1, 2021 21:34
Show Gist options
  • Save ndaidong/4c0e9fbae8d3729510b1c04eb42d2a80 to your computer and use it in GitHub Desktop.
Save ndaidong/4c0e9fbae8d3729510b1c04eb42d2a80 to your computer and use it in GitHub Desktop.
Install Go on Endeavour, Debian, Fedora
#!/bin/bash
export GO_VERSION=1.16.3
export GO_DOWNLOAD_URL=https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz
export GOROOT=/opt/go
export GOPATH=$GOROOT/packages
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
sudo mkdir $GOROOT
sudo chown -R ${USER} $GOROOT
if [ ! -f "go$GO_VERSION.linux-amd64.tar.gz" ]; then
wget "$GO_DOWNLOAD_URL"
fi
tar -zxvf go$GO_VERSION.linux-amd64.tar.gz
if [ -d "$GOROOT" ]; then
rm -rf ${GOROOT}
fi
mv go ${GOROOT}
echo "Installed Go v$GO_VERSION"
go version
# go get github.com/jesseduffield/lazydocker
@ndaidong
Copy link
Author

ndaidong commented Mar 12, 2018

Example:

VERSION=1.11.2 sh install-go.sh

.bash_aliases

export GOPATH=/usr/local/lib/go
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

@svarlamov
Copy link

I think that for most Go developers, it's more common (and IMO convenient) to put your GOPATH into your home directory, i.e., GOPATH=/home/ubuntu/gopkg

@bdbais
Copy link

bdbais commented Sep 25, 2018

apt: invalid flag: upgrade
Usage: apt
where apt options include:
-classpath Specify where to find user class files and annotation processor factories
-cp Specify where to find user class files and annotation processor factories
-d Specify where to place processor and javac generated class files
-s Specify where to place processor generated source files
-source Provide source compatibility with specified release
-version Version information
-help Print a synopsis of standard options; use javac -help for more options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system
-A[key[=value]] Options to pass to annotation processors
-nocompile Do not compile source files to class files
-print Print out textual representation of specified types
-factorypath Specify where to find annotation processor factories
-factory Name of AnnotationProcessorFactory to use; bypasses default discovery process
See javac -help for information on javac options.
....
go version
go version go1.6.2 linux/386
....
changed 1.10 in 1.10.1 on install script and apt-get .

@ndaidong
Copy link
Author

I think that for most Go developers, it's more common (and IMO convenient) to put your GOPATH into your home directory, i.e., GOPATH=/home/ubuntu/gopkg

I tend to create 2 different partitions and mount as /workspace and /storage, my GOPATH is being set to /workspace in which I have all the source codes, projects, etc

@ndaidong
Copy link
Author

apt: invalid flag: upgrade
Usage: apt
where apt options include:
-classpath Specify where to find user class files and annotation processor factories
-cp Specify where to find user class files and annotation processor factories
-d Specify where to place processor and javac generated class files
-s Specify where to place processor generated source files
-source Provide source compatibility with specified release
-version Version information
-help Print a synopsis of standard options; use javac -help for more options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system
-A[key[=value]] Options to pass to annotation processors
-nocompile Do not compile source files to class files
-print Print out textual representation of specified types
-factorypath Specify where to find annotation processor factories
-factory Name of AnnotationProcessorFactory to use; bypasses default discovery process
See javac -help for information on javac options.
....
go version
go version go1.6.2 linux/386
....
changed 1.10 in 1.10.1 on install script and apt-get .

thank you, just fixed and change to latest version 1.11.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment