Golang Installation and directory structure under Mac

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

1. Installation Steps

A. Download the SDK and unzip it to your favorite directory (you need to configure the path later)

B. Configure the path, there are many places can be configured to refer to this chain (path configuration in detail), I am directly modified ~/.bash_profile to set the environment variable, because the file can be changed by the general user, there is no permission issues involved, specifically refer to this link rough configuration. Enter in this file

Export goroot= $HOME/go

Export gopath= $HOME/go: $HOME/mygo

Export path= $PATH: $GOROOT/bin: $GOPATH/bin

Where Goroot corresponds to the previous go source package decompression path, Gopath can set a number to see where you want to create a new row, press: separate on the line as shown above

is so simple, the environment is configured, you can enter go at the command line to see if the installation is successful

2. Directory structure

A. Above I have linked a new Gopath:mygo, at this time switch to the folder under the new SRC folder (Go source folder, you need to build, not automatically generated)

B. Generally a complete go program below includes three subfolders of Src bin pkg.

Inside the bin is executable file through go install executable file, install the go file must contain the package main to produce the executable file

The pkg is filled with some corresponding. A file build can appear

C. So when you need a new go package, create a new folder under the SRC folder name is the same as the name of the go package you want, then just the code.

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.