Created
June 21, 2020 05:11
-
-
Save CloudLinuxDeveloper/24c7fe39d4a04d65d21e8210a93b7abb to your computer and use it in GitHub Desktop.
How to install Golang on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Download | |
sudo apt update | |
mkdir golang_source | |
cd golang_source | |
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz | |
sudo tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local | |
#Setup GOROOT and PATH environment variables: | |
echo 'export GOROOT=/usr/local/go | sudo tee -a /etc/profile | |
echo 'export PATH=$PATH:/usr/local/go/bin | sudo tee -a /etc/profile | |
source /etc/profile | |
#Test Golang | |
go version | |
go env | |
#Setup GOPATH and PATH environment variables (for bee tool): | |
sudo mkdir -p /usr/local/go_path | |
echo 'export GOPATH=/usr/local/go_path | sudo tee -a /etc/profile | |
echo 'export PATH=$PATH:/usr/local/go_path/bin | sudo tee -a /etc/profile | |
source /etc/profile | |
#You can write a simple Golang program and give it a shot: | |
cd /usr/local/go_path | |
sudo mkdir -p src/Falaq | |
cd src/Falaq | |
sudo nano helloFalaq.go | |
package main | |
import "fmt" | |
func main() { | |
fmt.Printf("hello, Falaq\n") | |
} | |
#Now save and exit | |
go run helloFalaq.go | |
#If everything was done correctly, you will see the output: | |
hello Falaq | |
#Now chenge the permision for user: | |
sudo chown -Rv falaq:falaq /usr/local/go_path | |
#Install Beego | |
go get github.com/astaxei/beego | |
#If you not installed Git before then install Git via this command otherwise you can skip. | |
sudo apt-get install git | |
#git https is not accessible. Please config local git and close https validation: | |
git config --global http.sslVerify false | |
#Install Bee tool | |
go get github.com/beego/bee | |
go install github.com/beego/be | |
#bee tool commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment