Install Third Party Packages

Install Third Party Packages

In this tutorial, we will discuss how do we install third party packages in the Go language.

Install Third Party Packages

We can download and install third-party Go packages by using go get command. The go get command will fetch the packages from the source repository and put the packages on the GOPATH location.

For example,

go get

The above command in the terminal will install “mgo”, a third-party Go driver package for MongoDB, into your GOPATH, which can be used across the projects put on the GOPATH directory.

After installing the mgo, put the import statement in your programs for reusing the code, as shown below:

import (        

The MongoDB driver, mgo, provides two packages that we have imported in the above import statement.

When using go get to install third-party packages, it is common for a package to be referenced by its canonical path. That path can also be a path to a public project hosted in a code repository such as GitHub.

As such, if you want to import the flect package, you would use the full canonical path:

$ go get

The go get tool will find the package on GitHub in this case and install it into your $GOPATH. For this example the code would be installed in this directory:


The original authors are often updating packages to address bugs or add new features. When this happens, you may want to use the latest version of that package to take advantage of the new features or resolved bugs.

To update a package, you can use the -u flag with the go get command:

$ go get -u

This command will also have Go install the package if it is not found locally. If it is already installed, Go will attempt to update the package to the latest version.

The go get command always retrieves the latest version of the package available.

Install Third Party Packages
Scroll to top