Build a Go language development environment in Linux, Windows, and Mac
Go language Official Website: https://golang.org/
Windows:
Download the go1.6.windows-amd64.msi installation file from the official website. Select the default installation path C: \ Go \
After installation, configure the environment variable Path: C: \ Go \ bin;
Next, create a GOPATH environment variable. This variable is very important. The code I wrote should be placed in the directory configured in this variable, and the go compiler will find and compile it;
Create a GOROOT variable, and use the GOROOT: C: \ go \; variable installed with the Go compiler \;
After completing the preceding steps, open the command line and enter # go version. The go compiler version is displayed.
Enter # go env to view the correct go environment.
Linux:
To deploy golang in Linux, first install the SSH remote tool on windows, such as Xshell4.
1. Install the mercurial package (the mercurial version management system can output the hg name to check whether the package is installed)
- Sudo apt-get install mercurial or # sudo easy_install mercurial
2. Install git
- Sudo apt-get install git
3. Install gcc
- Sudo apt-get install gcc
4. Download The golang compressed package
- Wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
- Tar-zxvf go1.6.linux-amd64.tar.gz-C/home
Rename the decompressed folder to go
Add environment variable: # vi/etc/profile
Add the following content to profile:
Export GOROOT =/home/go
Export PATH = $ GOROOT/bin: $ PATH
Export GOPATH =/home/gopkg
Change GOPATH and GOROOT to your path.
Then we refresh the environment variable: # source/etc/profile
Finally, verify whether the installation is successful: # go version
5. We can also install golang without downloading the compressed package.
- Sudo apt-get install golang
- Go version
Mac:
Download the go1.6.darwin-amd64.pkg installation file from the official website.
Alternatively, run the following command after installing homebrew:
- Brew update
- Brew install mercurial
- Brew install go
.
Enter # go version to see the version number of the go compiler.
Enter # go env to view the correct go environment.
I chose IDEA + go plugin as the development tool.
Websites: https://github.com/go-lang-plugin-org/go-lang-idea-plugin
Install go plugin:
File-> Setting, select "Plugins" on the left side of the Settings dialog box, and click "Browse repositories ",
Select Plugins on the left side of the Settings dialog box, Click Browse repositories, and click the Manage respositories button below.
In the Custom Plugin Repositories dialog box, click the + button.
In the "Add Repository" dialog box, enter the address of the go language plug-in: https://plugins.jetbrains.com/plugins/alpha/5047, and click OK .
In the Custom Plugin Repositories dialog box, click OK.
Next, find the "Go" plug-in on the left side of the "Browse Repositories" dialog box and click "Install.
After the restart, the Go language plug-in is installed.
File-> Project Structure: add the Go SDK to the SDKs.
Start to create the first go language program and run it:
OK. The go language development environment has been set up here. enjoy it ~
Getting started with Linux-installing Go in Linux
Install Go Language Pack in Ubuntu
Go language programming (HD) full-version ebook
Go language and beauty-surpassing "Hello World"
Why do I like the Go language?
Implementation of the Go language memory distributor
This article permanently updates the link address: