Last active
September 7, 2022 05:36
-
-
Save rakibulinux/1cc7d02b234d24cf5eba4768f291c8ba to your computer and use it in GitHub Desktop.
how to install golang and beego on ubuntu 18.04
This file contains hidden or 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 | |
| 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 | |
| #You can test golang installation with : | |
| sudo go version | |
| sudo 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/rakiblinux | |
| cd src/rakiblinux | |
| sudo nano hellorakib.go | |
| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Printf("hello, Rakiblinux\n") | |
| } | |
| #Now save and exit | |
| go run hellorakib.go | |
| #If everything was done correctly, you will see the output: | |
| hello Rakiblinux | |
| #Now chenge the permision for user: | |
| sudo chown -Rv rakib:rakib /usr/local/go_path | |
| #Install Beego | |
| go get github.com/astaxie/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 | |
| bee | |
| #Create new beego project with bee tool | |
| bee new rakib_linux | |
| cd src/rakib_linux | |
| #Now run the bee project | |
| bee run | |
| #You can try access it in your browser, | |
| http://your-ip:8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment