Install golang 1.9 on mac

PHPz
Release: 2023-05-10 10:25:36
Original
381 people have browsed it

For developers who need to install golang 1.9 on macOS, this article will provide a detailed step-by-step guide. Golang 1.9 is a popular programming language that is easy to learn and has excellent performance. It is one of the preferred languages ​​for many Internet companies and open source projects.

Step 1: Download golang 1.9

First, you need to download the golang 1.9 installation package from the official website http://golang.org/dl/. Select the installation package suitable for your operating system to download. Of course, you can also use the command line to download and install golang 1.9 as follows:

$ curl -O https://storage.googleapis.com/golang/go1.9.darwin-amd64.tar.gz
Copy after login

Step 2: Install golang 1.9

Installing golang 1.9 is very simple, just follow the steps below. Can:

  1. Open the terminal application.
  2. Extract the golang 1.9 tar file to the target folder.
$ tar -C /usr/local -xzf go1.9.darwin-amd64.tar.gz
Copy after login
  1. Get root privileges and add the go command to the system path.
$ sudo chmod -R 777 /usr/local/go
$ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bash_profile
$ source ~/.bash_profile
Copy after login

After completing the above steps, you have successfully installed golang 1.9.

Step 3: Set up the workspace

golang 1.9 uses the workspace to determine where the GO package is stored, including source code, binaries, and other related files. First, you need to create the workspace directory:

$ mkdir $HOME/go
Copy after login

Then, you need to set the workspace path. This can be set up by typing the following into the terminal:

$ export GOPATH=$HOME/go
Copy after login

Step 4: Test your golang 1.9 installation

Now you can test whether the version of golang you installed takes effect. You can create a simple go program in the terminal, compile and run the program:

$ cd $GOPATH/src
$ mkdir hello && cd hello
$ echo 'package main;import "fmt";func main() {fmt.Println("Hello, world!;")}' > hello.go
$ go build
$ ./hello
Hello, world!
Copy after login

If you see "Hello, world!", it means that your golang 1.9 is installed successfully.

Conclusion

The process of installing golang 1.9 is very simple. By following the steps above, you can quickly complete the installation and start building your next project using golang 1.9. Golang is becoming more and more popular because it provides excellent performance and efficient development experience.

The above is the detailed content of Install golang 1.9 on mac. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!