(Translated by https://www.hiragana.jp/)
How to Install Golang on MacOS? - GeeksforGeeks
Open In App

How to Install Golang on MacOS?

Last Updated : 02 Dec, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Before, we start with the process of Installing Golang on our System. We must have first-hand knowledge of What the Go Language is and what it actually does? Go is an open-source and statically typed programming language developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009. It is also known as the Golang and it supports the procedural programming language. It was initially developed to improve programming productivity of the large codebases, multicore, and networked machines. Golang programs can be written in any plain text editor like TextEdit, Sublime Text, or anything of that sort. One can also use an online IDE for writing Golang codes or can even install one on their system to make it more feasible to write these codes. Using an IDE makes it easier to write Golang codes because IDEs provide a lot of features like intuitive code editor, debugger, compiler, etc. In this article, we have covered the following topics:

Steps for Installing Golang on MacOS

Step 1: Checking if Go is installed or not. Before we begin with the installation of Go, it is good to check if it might be already installed on your system. To check if your device is preinstalled with Golang or not, just go to the Terminal and run the command:

go version

If Golang is already installed, it will generate a message with all the details of the Golang version available as shown below, otherwise, it will give an error. Step 2: Before starting with the installation process, you need to download it. So for that, all versions of Go for MacOS are available on https://golang.org/dl/ Download the Golang according to your system architecture. Here, we have downloaded go1.13.1drawin-amd64.pkg for the system. Step 3: After downloading process, install the package on your system: Step 4: After completing the installation processes. Open a program known as Terminal(It is a command-line interface for macOS) to check whether Go install properly or not using the Golang version command. As shown in the below image, here it shows the version information of the Golang which means Go install successfully in your system.

Setting up the Go Workspace

After successfully installing Go on your system, now we are going to set up the Go workspace. Go workspace is a folder on your computer where all your go code will going to store. Step 1: Creating a folder named as Go in documents(or wherever you want in your system) like as shown in the below image: Step 2: Now tell the Go tools to where to find this folder. So for that first of all, you go to your home directory using the following command:

cd ~

After that set path of the folder using the following command:

echo "export GOPATH=/Users/anki/Documents/go" >> .bash_profile

Here, we are adding export GOPATH=/Users/anki/Documents/go to .bash_profile. The .bash_profile is a file that automatically loaded when you logged into your Mac account and it contains all the startup configurations and preferences for your command-line interface(CLI). Step 3: Now check that your .bash_profile contains the following path using the following command:

cat .bash_profile

Step 4: Now we are going to check our go path using the following command. If you want to skip this step you can do that also.

echo $GOPATH

Creating first Golang program

Step 1: Download and install a text editor according to your choice. After installation, create a folder named go(or whatever name you want) in Documents(or wherever you want in your system). In this folder, create another folder named as source and in this source folder create another folder named as welcome. In this folder, all your go programs are going to be stored. Step 2: Let’s create first go program. Open the text editor and write go program as shown below: Step 3: After creating a go program save that program with extension .go. Step 4: Now open terminal to run your first go program. Step 5: Change the directory in which your program is stored. Step 6: After changing directory, run the go program using the following command:

go run name_of_the_program.go


Previous Article
Next Article

Similar Reads

How to Install Jupyter Notebook on MacOS?
> In this article, we will learn how to install Jupyter Notebook in Python on MacOS. The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text. Uses include data cleaning and transformation, numerical simulation, statistical modeling, da
2 min read
How to Install Google Chrome Browser on MacOS?
Google Chrome is a web browser. Google Chrome can be run on various platforms like macOS, windows, android, etc. It was made for the purpose of browsing web pages in an easy way. It was first launched in 2008. The development of google chrome goes to Google Inc. It is open-source software and it have many features like incognito mode, bookmarks, us
2 min read
How to Install Scrapy on MacOS?
In this article, we will learn how to install Scrapy in Python on MacOS. Scrapy is a fast high-level web crawling and web scraping framework used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing. Installation:Method 1: Using pip to insta
2 min read
How to Install Unity Hub on MacOS?
Unity software is used for the development of 2D and 3D games for computers, mobile, etc. It is developed by Unity Technologies in 2005 and is written in C# and C++ language. It is open-source software and free to use. It is a platform of the game engines. It is also used in the field of virtual reality. It was first introduced at Apple Inc.'s Worl
2 min read
How to Install VLC Media Player on MacOS?
VLC is also known as the VideoLAN client. It is a media player which is used to run media files like audio or video files. It is open-source computer software. The VLC media player is capable of running on several operating systems like macOS, Windows, Linux, Android, etc. It was first released in 2001 and is developed by VideoLAN and SourceForge.
2 min read
How to Install Jmespath-term on MacOS?
JMESPath is a JSON document manipulation expression language. If you're unfamiliar with JMESPath, it's a programming language that allows you to create a JMESPath expression that, when applied to an input JSON document, generates an output JSON document depending on the expression you gave. Experimenting with JMESPath expressions is one of the most
2 min read
How to Install SimpleJson Package for Python in MacOS?
SimpleJson is an open-source Python package. It is a fast, simple, and extensible Python JSON encoder and decoder. The encoder can be customized to provide serialization in any case without special support for serializing objects. For this purpose, the dump should be used as the default parameter. The decoder can handle any encoded JSON string (def
2 min read
How to Install MySQLdb module for Python on MacOS?
MySQLdb stands for My Structured Query Language Database and is an interface for connecting to a MySQL database server from Python. It is constructed on top of the MySQL C API and implements the Python Database API v2.0. Advantages of using MySQLdbData protection: MySQLdb is a very secure and reliable database, which is the reason why Twitter, Face
2 min read
How to Install Python docutils on MacOS?
Docutils is a system for converting documents into useful forms or meaningful formats like HTML, XML, and LaTeX. or we can say that it is an open-source text processing system. It supports reStructuredText as an input format, which is a simple, what-you-see-is-what-you-get textual markup grammar. It is written in Python language and supported by Py
2 min read
How to Install PyMedia for Python on MacOS?
PyMedia is basically a python library that can provide functionalities for audio as well as video processing. It supports a huge range of audio and video codecs, file formats, and protocols, which makes it a valuable tool for developers who's looking to build applications for the multimedia industry. The installation of PyMedia on MacOS is a simple
3 min read
How to Install Kotlin on MacOS?
Kotlin is an open-source programming language. It is developed by JetBrains and is designed to be a modern, safe, and efficient language for building modern applications. It is a functional language means it is based on the functional paradigm. It is a compiled language, which means it compiled to byte code and it is a multi-platform language also,
4 min read
How to Install Python chardet on MacOS?
The chardet module is mainly used to detect the character encoding in a text file. Or we can say that this module is used to take a sequence of bytes in unknown characters encoding and try to find the encoding so the user can read the text. It can detect the encodings like ISO-8859-8, windows-1255 (Visual and Logical Hebrew), ASCII, UTF-8, UTF-16 (
2 min read
How to Install Pytorch on MacOS?
PyTorch is an open-source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook's AI Research lab. It is free and open-source software released under the Modified BSD license. Prerequisites:PythonPython-pip or Anaconda-conda should be insta
2 min read
How to Install Julia on MacOS?
Julia is one of the new programming languages that is becoming popular with time. It is used mainly for scientific data calculations and mathematical analysis. It is becoming popular because it has very fast execution like C and simple syntax like python. It is an open-source language with high performance. Getting started Julia Codes can be writte
2 min read
How to install Solidity on macOS?
Solidity is a programming language used for writing smart contracts for many platforms of blockchain, the most common of which is ethereum. It is an object-based programming language that runs on EVM (Ethereum Virtual Machine) which executes the smart contracts. Below are the steps to install solidity in macOS - 1. Installing through npm command in
2 min read
How to Install Dart on MacOS?
The dart is an SDK (Software Development Kit) and SDK as you may observe from its name it is mainly a collection of software development tools that facilitate the creation of different applications, some of the tools include compilers debuggers libraries, and perhaps the software framework aiding towards the development process of creating. Support
2 min read
How to Install Visual C++ in MacOS?
Visual C++ is Software made by Microsoft Corporation. It is used to build desktop applications using the C and C++ languages. It was initially released in February 1993. In this article, we are going to learn how we can install Visual C++ in our Mac operating system. Installing Visual C++on MacOS: Follow the below steps to install macOS Step 1: Ope
1 min read
How to Install Code Blocks for C++ on MacOS?
Code::Blocks is a free and open-source IDE that supports a plethora of C++ compilers like GCC, Clang, and Visual C++. It is written in C++ and makes use of wxWidgets as the GUI toolkit. Code::Blocks is focused on C, C++, and Fortran development. It has a custom build system and optional Make support. In this article, we will discuss methods using w
2 min read
How to Install Rust nightly on MacOS?
Rust is a multi-paradigm, general-purpose programming language designed for safety and performance, especially safe concurrency. It is notable for enforcing memory safety. It is syntactically similar to C++ and is considered a systems programming language with the mechanisms for low-level memory management, but it also offers high-level features su
1 min read
How to Install Selenium WebDriver on MacOS?
In this article, we will learn how to install Selenium WebDriver in Python on macOS. Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used for automating web-based application testing to verify that it performs expectedly. Installation Procedure: Follow the below steps to install Selenium WebDriver
2 min read
How to Install Yarn in MacOs/Ubuntu/Windows?
Prerequisite: Difference between npm and yarn Yarn in layman’s term is a package manager that can be used in your code or a project that is currently being built, what yarn does is it helps to share the code with fellow mates or within a community of developers, and they can even run the project that we are building on their end. But how actually i
3 min read
How to Install Angularjs on MacOS?
AngularJS as the name suggests is a JavaScript-based framework. Being more precise AngularJS is an open-source front-end framework for the web. It is backed and maintained by Google. It has been in the market for a long time now, its initial release dated back to Oct 2010, and its last stable release was 12 months back in Oct 2020. AngularJS aims t
3 min read
How to Install Eclipse for C++ in MacOS?
C++ is basically a programming language. It is an Object-Oriented Programming Language. That means here we can use classes, objects, and other useful items. For developing purposes C++ is widely used. For this reason, we need to have an IDE. Eclipse is an IDE. It is used for many programming languages such as Java, C++, Python, and many more. For e
2 min read
How to install Blender on MacOS?
Blender is an animation software that was built for making 3D animations, but it is capable of creating both types of animations 2D as well as 3D. It is completely free software and its first version was launched in 1994. It is open-source software that was built using C++, Python, and C. The development credit of blender goes to Blender Foundation
2 min read
How to Install Brave Browser on MacOS?
Brave is a web browser that is made for browsing while keeping privacy and security at top. It is a free web browser that was launched in 2019. It is open-source software and the development credit of this browser goes to Brendan Eich and Brave Software, Inc. Brave browser can be used on different operating systems like macOS, Windows, Linux, Andro
2 min read
How to Install Pyglet in Python on MacOS?
In this article, we will learn how to install Pyglet in Python on MacOS. Pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. Installation:Method 1: Using pip to install Pyglet Follow the below steps to install the Pyglet package on macOS using pip: Step 1: Insta
2 min read
How to Install SQLmap on MacOS?
Sqlmap is an open-source penetration testing tool. It is used to find and exploit SQL injection problems and take control of database systems. It contains a robust detection engine, and various special features for the ultimate penetration tester, and a wide range of switches that span database fingerprinting, data retrieval from databases, access
2 min read
How to Install wxPython on MacOS?
In this article, we will learn how to install wxPython in Python on MacOS. The wxPython is a cross-platform GUI toolkit for the Python language. With wxPython software developers can create truly native user interfaces for their Python applications, that run with little or no modifications on Windows, Macs, and Linux, or other Unix-like systems. In
2 min read
How to Install xlrd in Python on MacOS?
In this article, we will learn how to install xlrd library in Python on macOS. The xlrd is a library for reading data and formatting information from Excel files in the historical .xls format. Installing xlrd Library on macOS:Method 1: Using pip to install xlrd Follow the below steps to install the xlrd library on macOS: Step 1: Install the latest
2 min read
How to Install COBOL on MacOS?
COBOL is a compiled English-like computer programming language designed for business use. It is an imperative, procedural, and, since 2002, object-oriented language. COBOL is primarily used in business, finance, and administrative systems for companies and governments. In this article, we will look at the process of installing COBOL in MacOS. Insta
2 min read
three90RightbarBannerImg