Instructions on how to install Go Lang on MacOS with Homebrew.

---
title: Install Go Lang on MacOS with Homebrew
subtitle: Install go on Mac with Homebrew
author: Ahmad Awais
date: May 23, 2018
source: https://ahmadawais.com/install-go-lang-on-macos-with-homebrew/
notoc: false
---

I've started learning [Go Lang](https://golang.org). It seems to be built by the
right people with the right expectations. So, the first thing I did was install
go on Mac with [Homebrew](https://brew.sh).

## Installation

1. First of all **export some paths**, and save them in your `.zshrc` or
   `.bashrc` files for easy use (try using `sudo` if you get any errors).

    ```bash
    # Go development (https://ahmadawais.com/install-go-lang-on-macos-with-homebrew/)
    export GOPATH="${HOME}/.go"
    export GOROOT="/usr/local/opt/go/libexec"
    export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
    [ -d "${GOPATH}" ] || mkdir "${GOPATH}"
    [ -d "${GOPATH}/src/github.com" ] || mkdir -p "${GOPATH}/src/github.com"
    ```

2. Then finally install go, with **Homebrew**.

    ```bash
    brew install go
    ```

## Extra

### Go Dev Tools

#### Golint

[Golint](https://github.com/golang/lint) is a linter for Go source code.

```bash
# Install Golint:
go get github.com/golang/lint/golint
```

---

### Go Editor Integrations

#### SublimeText

- [Go‚ÄčSublime](https://packagecontrol.io/packages/GoSublime) -- *A Go Lang plug-in collection for SublimeText 3, providing code completion and other IDE-like features.*

#### Visual Studio Code

- [Go](https://marketplace.visualstudio.com/items/lukehoban.Go) -- *Rich Go Lang support for Visual Studio Code.*

### Awesome Go Packages

#### node-prune

[node-prune](https://github.com/tj/node-prune) is a small tool to prune unnecessary files from `./node_modules`, such as markdown, typescript source files, and so on. Primarily built for [Up](https://github.com/apex/up) which lets you deploy server-less web applications in seconds.

```bash
go get github.com/tj/node-prune/cmd/node-prune
```