"Golang" study note 1--Windows Go installation and development environment configuration

Source: Internet
Author: User
Tags install go

Objective

This article mainly records the development environment configuration under Windows Golang.

Install Go

Three ways to install go

Go has a variety of installation methods, the more common is the following three kinds:

    • Go source installation: This is a standard way to install software. For users who frequently use Unix-like systems, especially for developers, installation from the source can be customized by themselves.
    • Go Standard Pack Installation: Go provides a convenient installation package that supports Windows, Linux, Mac and other systems. This method is suitable for quick installation, can download the corresponding installation package according to your own system, the next complete. This method is generally recommended.
    • Third-party tool installation: There are many handy third-party package tools, such as Ubuntu Apt-get and wget, Mac Homebrew, and so on. This installation is the same as the first, and is suitable for users who are familiar with the appropriate system.

I am using the standard package installation under Windows.

Install package download

Access to the Golang download page, according to their own system to choose a different installation package for installation, Bo Master's system is 64-bit, so the download is windows-amd64. Run after download, * * Do not modify the default installation directory c:\go**, if installed to another location may lead to the inability to execute their own written Go code. Setup defaults to add the bin directory C:\Go\bin in the Go installation directory after the environment variable Path and add the environment variable goroot, which is the go installation root C:\Go.

Verify that the installation is successful

Enter CMD in the run to open the command-line tool, enter go at the prompt to check if you can see the Usage information. Enter the CD%goroot% to see if you can go to the Go installation directory. If successful, the installation is successful.
If not, check the values of the above environment variables Path and goroot.

Gopath and working space

Gopath Introduction

Gopath,go command relies on an important environment variable, go from 1.1 to 1.7 must set this variable, and can not be the same as the Go installation directory. There are three subdirectories under this directory: src, bin, pkg, respectively, to store the go source, the executable file, and the corresponding compiled package file.

src 存放源代码(比如:.go .c .h .s等)pkg 编译后生成的文件(比如:.a)bin 编译后生成的可执行文件(为了方便,可以把此目录加入到 $PATH 变量中,如果有多个gopath,那么使用${GOPATH//://bin:}/bin添加所有的bin目录)

Starting with Go 1.8, if Gopath is not set, there will be a default value for%userprofile%/go on Windows.

Set Gopath

Click Computer--System Properties--Advanced system settings-environment variables--Create a new environment variable or system variable called Gopath.

Specify this variable to a directory, such as the blogger setting D:\myGoPath .

Gopath allows multiple directories (the contents of Go get will be placed in the first directory by default.) ), multiple directories windows are separated by semicolons.

At this point, our development environment is configured, next we introduce the directory structure of the Code, application compilation, reference and how to get the remote package.

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.