Golang Starter Series (i) Go environment construction

Source: Internet
Author: User
Tags install go
Install Go

The pros and cons of Go language, here is not introduced, the following directly talk about the installation of Go:

Go official website : http://golang.org/(requires FQ software)

Domestic : http://www.golangtc.com/download

Download the installation package for the corresponding platform. Note whether the 32-bit or 64-bit operating system is distinguished.

After the installation package has been downloaded, the installation process is simple, and the next step is just fine.

Go Environment variables

When you install go, the installer automatically writes the relevant directory to the system environment. But if it is a zip installation, you need to manually add it yourself.

The main configuration is as follows:

    • Goroot:go the installed root directory (for example: D:\Go), the Setup program is automatically written to the system environment variables during installation.
    • Gobin:go binary File storage directory (%goroot%\bin)
    • Path: You need to add%gobin% to the end of the PATH variable for easy operation at the command line.

When the environment variable is configured, Go is already installed. Open the command line and run the GO command to see the following prompt.

Go Working space

Gopath:go Workspace is our development and Dependency package directory (ex: My is D:\Go_Path\go), this directory needs to be manually configured to the system environment variables

The Gopath workspace is a directory hierarchy with three subdirectories in its root directory:

    • SRC: include Go source file, Note: You create your own dependent package, also put in the Gopath directory, so that can be referenced.
    • PKG: Contains package object, compiled library file
    • Bin: Contains executable commands

Attention:

1. The Gopath path needs to be manually written to the system environment variable.

2. Do not set the Gopath as the Go installation path

3. You create the dependent package yourself and put it in the Gopath directory so that it can be referenced.

Once configured, use the Go ENV command to see if the GO environment is configured correctly:

Hello World

Now, let's get up to Hello World!

Package Mainimport (    "FMT") Func main () {    fmt. Println ("Hello world!" ) }

Save the above program to Helloworld.go and then execute it on the command line:

Go Run helloworld.go

Other

1. IDE download install here do not say, we go directly to this address download on the line.

goland:www.jetbrains.com/go/download/#section =windows

Liteide:studygolang.com/dl This is the newest 1.10.3, Free IDE

2. I'm using the Atom editor. Configuration is a bit cumbersome, not recommended for everyone to use.

3. How to use the go language directly behind.

4. Can turn the best FQ, because many package in Golang official website, not FQ download not down.

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.