SwiftlySingh

Share this post

What is Golang? How to Install it on a mac

swiftlysingh.substack.com

What is Golang? How to Install it on a mac

Pushpinder Pal Singh
Nov 13, 2019
Share this post

What is Golang? How to Install it on a mac

swiftlysingh.substack.com

In one line, Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. This is what golang.org describes Golang as.

Let me be honest, that defination is for noobs. Not experienced coders like you and me. (Even if you are coding for 2 days I would categorize you in the experience bucket here).

So you might be thinking why the hell should I switch from the language I am currently learning and/or use to Go?

Allow me to answer your questions that might be jumping in your head and give a compelling reason to switch to Go.

Benefits of Go

Go is Open-source

It’s incredibly important for a programming language to be open-source to become better, cleaner, and more efficient.

Go is Fast

Go has a simple structure and syntax. It is devoid of classes and type inheritance. The language is based on functions, so it is simple and fast to learn. It’s compiled so it provides faster feedback, shorter time to market, and saves time and money. It’s simple, so it is more maintainable, and development is faster and cheaper.

Go is Concurrent

Concurrency is extremely important at our time. It allows multiple processes running simultaneously and effectively.

Golang has efficient concurrency, like C, C++, Java, and at the same time concurrency in Go is done much easier thanks to goroutines, channels, and garbage collection.

Go has a Garbage Collector

A form of automatic memory management which has a significant influence on performance and helps to make concurrency more efficient.

Convinced that Go has an opportunity for becoming your second/third or even nth language? Let’s go ahead with the installation.

Ohh what’s that? Not yet convinced? Go and research Go. Here is the Geeks for Geeks page for your reference.

Installation

Although this guide will be mac specific but Installation on windows should be pretty similar. (Some cmd commands might change on windows).

  1. You will be needing a text editor for you to code in go. My favourite is VS code and you could install it here.

  2. Go to this link and download the installation file compatible with your device

  3. Open the downloaded file and start the installation wizard, you only need to press next until the installation is completed.

  4. The installation is technically complete but we should do a test if its properly installed.

Testing

  1. Open your terminal. From this point on windows peeps might want to google some commands.

  2. Copy and paste into terminal << mkdir $HOME/go/src/hello >> (you need to only copy commands written inside << >>) This command will setup a new workspace for your project named “Hello”.

  3. Copy and paste << touch $HOME/go/src/hello/hello.go >> . This will create a file for your new project

  4. Go into your directory using << cd $HOME/go/src/hello/ >>

  5. Now open the above file in VS Code using << open hello.go >>

  6. For a test copy this code

package main
import "fmt"
func main() {    fmt.Printf("hello, world\n")}

7. Build your app in the terminal using << go build >>

8. Get your output i.e. “Hello World” using << ./hello >>

Originally published at TechnicalNow.in.

Share this post

What is Golang? How to Install it on a mac

swiftlysingh.substack.com
Comments
TopNew

No posts

Ready for more?

© 2023 Pushpinder Pal Singh
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing