Menu Close

Go – How to install and setup go on mac

Here, We will look into how to install and setup go on mac. You can follow given below steps to install and run go program on your mac.

Steps to install go on your mac:

  • Run command on terminal: brew update
  • brew install go or brew install go@latest

Add given below global variables into ~/.bashrc file. Default path of .bachrc file is ~/.bashrc.

export GOPATH=$HOME/go-workspace

export GOROOT=/usr/local/opt/go/libexec

export PATH=$PATH:$GOPATH/bin

export PATH=$PATH:$GOROOT/bin

Create your workspace:

mkdir $GOPATH 

mkdir $GOPATH/src 

mkdir $GOPATH/pkg 

mkdir $GOPATH/bin

$GOPATH/src: Path to your go project

$GOPATH/pkg: contains every package objects

$GOPATH/bin: Path to compiled binaries

Sample go program:

package main

import "fmt"

func main() {

  fmt.Println("hello go")



A02YZ14CLVEE:src admin$ go run sample.go
hello go

To learn more about golang, Please refer given below link:


Posted in networking

Leave a Reply

Your email address will not be published. Required fields are marked *