Go installation configuration process

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

The Go language supports the following systems:

    • Linux
    • Freebsd
    • Mac OS X (also known as Darwin)
    • Window

The download address for the installation package is: https://golang.org/dl/.

Installation:

Download: go1.3.darwin-amd64-osx10.8.pkg

Default installation, the/usr/local/go directory is installed

and set the environment variable.

Go env to view the current environment variables for Go

Configuration:

According to the Convention, 3 directories need to be established under Gopath:

    • Bin stores the compiled executable file

    • Pkg to store package files generated after compilation

    • SRC Store The source code of the project

I built Gopath on/users/apple/documents/gowork.

cd ~open .bash_profile加入:export GOPATH=/Users/zhaorai/Desktop/gowork

Gowork directory:

To take effect immediately please run:

source ~/.bash_profile

Test examples:

//hello.go  package mainimport"fmt"//实现格式化的I/O /*Printf someting*/func main(){         fmt.Printf("Hello,World!\n")  }

In terminal execution:

bo build helloworld.gobo run helloworld.go

Execution Result:

Hello,World!

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.