Open In App

How to Install a package with GO get?

Last Updated : 01 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In the Go language, we can use the go get command to download and install the packages and dependencies. Various repositories have the support to go get like Azure Repos Git and GitHub Repos. Executable is installed in the directory named by the GOBIN environment variable which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set. In this article, we will install a package using the go get command. Here, we will be using Linux Operating System.

Note: Make sure you have the Golang environment set on your operating system.

Installing a Package using go get

To install a package using go get follow the following steps: 

Step 1: Make sure to check whether the Golang is installed on your system by checking the version of Go.

go version

Checking-the-version-of-golang

Step 2: Set the GOPATH by using the following command.

export GOPATH=$HOME/go

Setting-the-GOPATH

Step 3: Now, set the PATH variable with the help of the following command.

export PATH=$PATH:$GOPATH/bin

Setting-the-path-variable

Step 4: Now, check the ./bashrc file in Linux whether the path variables are successfully set or not.

nano ~/ .bashrc

Checking-the-path-variables-are-successfully-set-or-not

Step 5: Below is the GitHub repository which we will be downloaded by using the go get command.

https://github.com/haccer/subjack

Github-repository

Step 6: Use the following command to download the repository to the local file system.

go get github.com/haccer/subjack

Downloading-the-github-repository-using-go-get

Step 7: Install the executable by using the following command.

go install -v github.com/haccer/subjack@latest

Installing-the-executable

Step 8: The repository is been successfully downloaded and we are just checking the help section of the repository.

subjack -h

Checking-the-repository-downloaded-successfully-or-not


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads