Skip to content

Mukul Kadel

Menu
  • Home
  • Blogs
  • Categories
  • About
  • Contact
Menu

Getting started with Go (Mac)

Posted on June 14, 2024

Welcome to my blog! In this post, I’ll guide you on how to set up Go (Golang) on a Mac and run a basic “Hello, world!” program.

Go is an open-source, statically typed, compiled language. It’s very clean and efficient, and its concurrency mechanisms make it easy to get the most out of multicore systems.

Prerequisites

  • A basic code editor.
  • A code terminal.
  • Homebrew

How to install

  • Open terminal.
  • Run the following command:
Bash
brew install go

This command will install the latest version of Go.

If you want to install a specific version, use the command below:

Go
brew install go@1.22.4

  • Run the command below to test the installation:
Bash
go version
# output: go version go1.xx.x darwin/arm64

  • Now, set up environment variables by running the commands below:
Bash
export PATH="$PATH:$HOME/go/bin"
echo "export PATH=\"$PATH:$HOME/go/bin\"" >> ~/.zprofile

Your Go setup is complete. Let’s now explore how to run it!

A Simple Program: Hello, World!

  • Make a new directory demo & open a new file main.go in it.
Bash
mkdir demo
cd demo
nano main.go # You can also use an IDE.

  • In the file, paste the code below and run go run main.go in the terminal:
Go
package main

import "fmt"

func main() {
	fmt.Println("Hello, World!")
}

You should see the following output in the terminal:

Go
Hello, World!

Congratulations on your first Go program!

Share on Social Media
x facebook linkedin reddit

Recent Posts

  • Ikigai: 10 Rules to a Fulfilling Life
  • Getting started with Go (Mac)
  • The Apple Event 2024: A Glimpse into the Future of Technology
  • Master SQL: A Comprehensive Guide to DDL, DML, DCL, and TCL
  • How “Atomic Habits” is Changing My Life

Social Links

  • Twitter
  • Instagram
  • Linkedin
  • Github
©2025 Mukul Kadel | Design: Newspaperly WordPress Theme
Menu
  • Home
  • Blogs
  • Categories
  • About
  • Contact