Mac down go development environment building

Source: Internet
Author: User
Tags install go
This is a creation in Article, where the information may have evolved or changed.

Recently by colleagues to mention go, probably understand the next, go language is actually more an engineering language, in the server development, concurrency and other issues on the provision of a set of native solutions, at the same time in the programming mode and the use of simple doctrine, code concise, strong performance, although the pit more, But now also more and more people adopt go as their own project language, so I also want to summarize a topic in my spare time, record oneself start to learn go, although the content is very simple, but I hope to still be able to do the content of concise and error-free, help Yimeimei.

1, Go development environment installation

Because I am using a Mac computer, so here only on the Mac computer to use the go language of the relevant operations, first in the Mac can actually not be used to install the source, the Go project provides a Mac under the installation package, can download the installation package directly click Install, because the original URL may be the wall, Here is a mirror address for your reference: Http://www.golangtc.com/download, after installation, open the terminal input go or go version:


If you are prompted that the GO command does not exist, the current path of Go is not in the environment variable and needs to be added manually, refer to the following steps.

2, GO environment variable add

In general, you need to add three main environment variables for go, namely Goroot, Gopath, and Go command path, the installation package Click Install Go location default to/usr/local/go, so you need to add/usr/local/go/bin to path , and Goroot is the installation directory/usr/local/go,gopath is generally a custom directory, for storing you will be the source location, such as $home/go, modify environment variables can be modified by modifying the current user directory under the configuration file:

Vim ~/.bash_profile

The modifications can be similar to the following:


After the modification is complete, the source ~/.bash_profile is executed to make the configuration effective, and then the Go Version command returns with step 1.

3. Hello World Program

when we learn a new language, the output Hello World is a sentimental start, and here is no exception, create a new Hello.go file under the Gopath directory you created  

Package Mainimport "FMT" Func Main () {   fmt. Printf ("Hello, world!\n")}

After saving, executing the Go build hello.go command will generate a hello executable file, execute the./hello, then go through the go development process.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.