JIYIK CN >

Current Location:Home > Learning > PROGRAM > Go >

Install GoLang using Brew

Author:JIYIK Last Updated:2025/04/15 Views:

This article describes how to install GoLang using Brew on Linux or macOS.


Install GoLang using Brew

brew installs missing packages in Linux and macOS. It makes it easy to install GoLang on Linux or macOS.

Follow the steps below to install GoLang on Linux or macOS using the brew command.

  1. First, brew should be installed; if not already installed, run the command mentioned below. It may require administrator privileges and take a while.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    Brew Install

    We have to run a few more commands to complete the brew installation. Run the following three commands to add Homebrew to your PATH and make sure the path is correct.

    In our example:

    ```bash echo '# Set PATH, MANPATH, etc., for Homebrew.' >> /home/sheeraz/.profile echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/sheeraz/.profile eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ``` To install Homebrew's dependencies, use the following commands: ```bash sudo apt-get install build-essential ```
  2. After installing brew, the next step is to update it and install Golang. Run the following commands:
    brew update && brew install golang
    
    Brew Install Golang
  3. The command above will install GoLang using brew command; the next step is to set up the workspace. We use the path $HOME/go to set up our workspace and run the following command:
    mkdir -p $HOME/go/{bin,src,pkg}
    
  4. One more important step is to set up the environment for Golang; to do this, we need to add the following information to our .bashrc file:
    export GOPATH=$HOME/go
    export GOROOT="$(brew --prefix golang)/libexec"
    export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
    
    Now we can use GoLang and create a project with a src directory in the go path.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Getting a string representation of a structure in Go

Publish Date:2025/04/15 Views:63 Category:Go

Go allows us to serialize data from structures using a variety of simple standard methods. Converting a structure to a string using String method in Go The GoLang package String helps implement simple functions to manipulate and edit UTF-8

Convert JSON to struct in Go

Publish Date:2025/04/15 Views:126 Category:Go

This article describes how to convert JSON to struct in GoLang . Convert JSON to Struct using Unmarshal method in Go The encoding/json package of the Go language provides a function Unmarshal to convert JSON data into byte format. This func

Golang 中的零值 Nil

Publish Date:2023/04/27 Views:185 Category:Go

本篇文章介绍 nil 在 Golang 中的含义,nil 是 Go 编程语言中的零值,是众所周知且重要的预定义标识符。

Golang 中的 Lambda 表达式

Publish Date:2023/04/27 Views:699 Category:Go

本篇文章介绍如何在 Golang 中创建 lambda 表达式。Lambda 表达式似乎不存在于 Golang 中。 函数文字、lambda 函数或闭包是匿名函数的另一个名称。

Go 中的深度复制

Publish Date:2023/04/27 Views:136 Category:Go

当我们尝试生成对象的副本时,深层副本会准确复制原始对象的所有字段。 此外,如果它有任何对象作为字段,也会制作这些对象的副本。本篇文章介绍如何在 Golang 中进行深度复制。

在 Go 中捕获 Panics

Publish Date:2023/04/27 Views:104 Category:Go

像错误一样,Panic 发生在运行时。 换句话说,当您的 Go 程序中出现意外情况导致执行终止时,就会发生 Panics。让我们看一些例子来捕捉 Golang 中的Panics。

Go 中的日志级别

Publish Date:2023/04/27 Views:589 Category:Go

本篇文章介绍如何在 Golang 中创建和使用日志级别。Go 中的日志级别。Golang提供了一个日志包,名为log,是一个简单的日志包。 这个包不提供分级日志; 如果我们想要分级日志记录,我们必须

在 Go 中使用断言

Publish Date:2023/04/27 Views:593 Category:Go

本篇文章介绍了 assert 在 GoLang 中的使用。在 Go 语言中使用断言:GoLang 不提供对断言的任何内置支持,但我们可以使用来自 Testify API 的广泛使用的第三方包断言。

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial