GithubHelp home page GithubHelp logo

go-installation-on-linux's Introduction

Customized installation Golang on Linux

COMPILERS FOLDER

Example: mkdir {compilers,compilers/c,compilers/go,compilers/rust}

mkdir {compilers,compilers/go}
cd compilers/go

VERSION

mkdir go1.17.6.linux-amd64 && cd go1.17.6.linux-amd64

DOWNLOAD

wget https://dl.google.com/go/go1.17.6.linux-amd64.tar.gz
  • Write the command dir then hit Enter to check if the folder go1.17.6.linux-amd64.tar.gz is completely downloaded.

EXTRACT & REMOVE

tar -xvf go1.17.6.linux-amd64.tar.gz
rm go1.17.6.linux-amd64.tar.gz

WORK SPACE

IF there is no such file or directory "~/dev/golang/workspace", then create this directory

cd ~
mkdir {dev,dev/golang,dev/golang/workspace}

Or go to the Golang development directory like so

cd ~/dev/golang/workspace

Workspace required to enable Golang versions

mkdir go1.17.6 && cd go1.17.6
mkdir {bin,pkg,src,src/github.com,src/github.com/your-github-name}

An example of what a workspace looks like

workspace
├── go1.15.7
├── go1.16
├── go1.16.2
├── go1.16.3
├── go1.16.4
└── go1.17.6
    ├── bin
    ├── pkg
    └── src
        └── github.com
            └── your-github-name

PATH

Open the terminal path file by writing

gedit $HOME/.bashrc

OR

gedit ~/.bashrc

Copy, Paste & Save the following code at the end of the .bashrc file, then close it.

## Changes made to the .bashrc file by myself
## GOROOT
export GOROOT=$HOME/compilers/go/go1.17.6.linux-amd64/go
export PATH=$PATH:$GOROOT/bin

## GOPATH
export GOPATH=$HOME/dev/golang/workspace/go1.17.6
export PATH=$PATH:$GOPATH/bin

## GOBIN
export GOBIN=${GOPATH}/bin

Note: only one version must be active

CHECK

Close the terminal and open it again

go version
  • go version go1.17.6 linux/amd64
go env
  • GO111MODULE="auto"
  • GOPATH="/home/<your-usr-name>/dev/golang/workspace/go1.17.6"
  • GOBIN="/home/<your-usr-name>/dev/golang/workspace/go1.17.6/bin"
  • GOROOT="/home/<your-usr-name>/compilers/go/go1.17.6.linux-amd64/go"
  • GOCACHE="/home/<your-usr-name>/.cache/go-build"
  • GOENV="/home/<your-usr-name>/.config/go/env"
  • GOMODCACHE="/home/<your-usr-name>/dev/golang/workspace/go1.17.6/pkg/mod"
  • GOTOOLDIR="/home/montasir/compilers/go/go1.17.6.linux-amd64/go/pkg/tool/linux_amd64"

TEST PROJECT

go get github.com/gorilla/mux
cd dev/golang/workspace/go1.17.6/src/github.com/your-github-name
git clone https://github.com/dr-montasir/go-rest-api.git
cd go-rest-api/go-mock-rest-api
go build
go run main.go

OR

./go-mock-rest-api

Open your browser and test the project

http://localhost:1400/api/courses
[
  {
    "id": "1",
    "category": "Web Development",
    "title": "Build Web Apps with Go Language",
    "instructor": { "firstName": "Rob", "lastName": "Pike" },
    "cousreDuration": "4 months"
  },
  {
    "id": "2",
    "category": "Mobile App Development",
    "title": "Build Mobile Apps with Flutter Dart",
    "instructor": { "firstName": "Lars", "lastName": "Bak" },
    "cousreDuration": "5 months"
  }
]

How to test the project outside of GOPATH?

cd ~/Desktop
git clone https://github.com/dr-montasir/go-rest-api.git
cd go-rest-api/go-mock-rest-api
go build

OR

go build -o alternative-project-name main.go

PREVIOUS VERSIONS

go-installation-on-linux's People

Contributors

dr-montasir avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.