Go: Setting Up

Learning Golang has been interesting.  One of the basic setup secrets I don’t see talked about very much.  However, an instructor on Go (over at Udemy) showed that if you setup your go environment properly you’ll be able to pulldown github repos, build and install binaries into the appropriate folders.

Directory Setup

After installing Go on your OS, go to the terminal and run:

go env

You’re looking for the GOPATH. Mine is:


Go to that folder in your path and create the following sub folders:




Within the src folder we’ll make a sub folder: 


Once done, if you do a go get

it will download the repo into the ../go/src/[git username of repo you pulled]

Build vs. Install

In Go you compile your apps for the target system the app will run on, as there’s no JVM (or similar technology) in Go.

If you do a: go build (while inside the code directory) it will build out a binary (exe for example) in the folder.

However, if you run: go install it will compile the binary but place it in your GOPATH / bin

What’s nice about go install, is that the /bin folder in Go is on the PATH, so you can execute your new binary from any location on the system.

For those executables created with go build, you can clean up your workspace with: go clean and all the binaries created (but not installed) will be removed.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

YouTube will probably ban my account… here’s why

Go – Package Scope