01-get-started/ubuntu-installation.md
If you want to use snap, you can easily install Go like so:
sudo snap install go --classic
Otherwise, please follow the steps below:
sudo apt-get update
sudo apt-get install git
There are two ways:
1- From Web: Select Linux and the download will begin.
firefox https://golang.org/dl
2- By using snap: If you use this option, skip to the 5th step.
sudo snap install go --classic
Find out the name of the downloaded file
Use that filename to uncompress it
gofile="DELETE_THIS_AND_TYPE_THE_NAME_OF_THE_DOWNLOADED_FILE_HERE (without its extension)"
tar -C /usr/local -xzf ~/Downloads/$gofile
Add go/bin directory to $PATH to be able to run the fundamental Go commands.
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
Add "$HOME/go/bin" directory to $PATH
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.profile
These are very handy tools to ease the development (like goimports)
go get cannot be used without installing a code versioning program like Git which we already have got it above.
This will create ~/go directory and will download go tools into there.
go get -v -u golang.org/x/tools/...
Note: You may use another coding editor if you like. However, the course uses Visual Studio Code (VSCode).
Open "Ubuntu Software" application
Search for VSCode then click "Install"
Create a hello.go file in a new directory but anywhere outside of $GOPATH
cat <<EOF > hello.go
package main
import "fmt"
func main() {
fmt.Println("hello gopher!")
}
EOF
Run the program
go run hello.go
It should print: hello gopher!
For more tutorials: https://blog.learngoprogramming.com
Copyright © 2018 Inanc Gumus
Learn Go Programming Course