This is a creation in Article, where the information may have evolved or changed.
Recently, as a result of work needs, began to contact a new language--golang,golang is a compiled, parallel, and garbage-collected programming language developed by Google. For people who are familiar with Java, in the language habits of some do not adapt, personal feel more like JS and C combination version, slowly familiar will feel is a very good language, fast, high performance. Really worth learning to understand.
As the company's main development is under the Linux system, the familiar configuration is still under Linux, but also a simple description of the Windows configuration.
Golang Download Address: www.golangtc.com/download
In this download address has a download third-party package connection, is mainly used to download some development needs of the dependency package, due to the relationship between the Chinese wall, code.google.com above a lot of packages can not be downloaded, in accordance with this download third-party Package interface operation to download, is very convenient.
First, under Windows configuration Golang Environment
First of all, download Go1.4.2.windows-amd64.zip to any folder, my computer is Win7 64-bit, so download is AMD64 version, 32 friends download 386 version can be.
After downloading the zip compressed package, get the folder called Go, where the Go folder belongs to the root directory of Golang, the configuration of the Java environment of the friend may have understood my meaning, put the go this folder to configure the environment in any location, such as I put directly under the D disk, So the root directory of Golang is d:/go.
The next step is to configure the go environment, under computer desktop, the advanced system settings, such as properties, and environment variables, add two new variables--goroot and Gopath to the system variables.
Here's a quick explanation:
Goroot refers to the root directory of Golang, that is, the blogger's address d:/go just mentioned;
Gopath refers to the Golang work path, this work path can be arbitrarily assigned, it is recommended not and Golang root directory together, in order to avoid later due to accidental deletion of files and other operations caused problems.
The Gopath convention has three subdirectories:
1.SRC store source code (e.g.,. Go. C. h, etc.);
2.PKG files generated after compilation (e.g.. a);
The executable file generated after 3.bin compilation.
It is recommended to manually generate SRC, pkg, bin three sub-folders under the Working Path folder while specifying the working path of the Golang, such as specifying D:/goworkspace as Gopath, then manually generate SRC under the Goworkspace folder, Pkg and bin three subfolders, the advantage is that later using the Golang command, such as go install the Go package will be much more convenient, but also convenient code management and maintenance.
As stated above, the value of Goroot is set to D:/go, and the value of Gopath is set to D:/goworkspace. Finally, set the value of the path system variable, and add%goroot%\bin; The Golang environment configuration is complete under Windows.
Open the console via CMD, enter go, and if you see the following interface, it proves that the Golang environment under Windows has been configured to complete.
Second, the Linux configuration Golang environment
When you're done with Windows, go back to the Linux configuration. Here I use the LinuxMint 64-bit virtual machine, I am not familiar with Linux, so still with the interface of Linux.
First, download the go1.4.2.linux-amd64.tar.gz compressed package and put it in any directory you want.
For example, to specify the installation directory for/soft, perform tar-zxvf go1.4.2.linux-amd64.tar.gz-c/soft command to decompress;
Execute sudo gedit. Profile to open the Linux environment variable file, in which you add
Goroot=/soft/go
Gopath=/soft/repositories/gpath
Path= $GOROOT/bin: $PATH
After saving, exit the profile file and execute the Source Profile command to complete the configuration.
Similarly, the Go command, as shown, proves that the environment is configured successfully.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.