This is a creation in Article, where the information may have evolved or changed.
pycharm Build Go development environment is not too difficult, cough, the main oneself did not understand the configuration and use of Goroot and Gopath took a detour, deliberately recorded this process. Detailed introduction for the benefit of the public! (I am the Windows environment, Linux, MAC OS is similar)
1. Go Language SDK installation package download and install
First go to Golang official website (https://golang.org/dl/) Download the SDK, need to turn over the wall, the author uses is lantern (Https://github.com/getlantern ... )
Download the corresponding files for installation, the author chooses the installation directory is: F:\golang .
2. Goroot and GOPATH environment variable configuration
2.1 ConfigurationPATH
Select Advanced System configuration, environment variables, PATH add the bin path to the go on the end of the corresponding value, notice that there is a semicolon in front;
2.2 Configuring Goroot
In the System variables box, create a new GOROOT variable with a value of the installation path:
2.3 Configuring Gopath
GOPATHis the Go project directory, is the next directory to write the program, I put in E:\GoProjects , in the system variable box, the new GORATH variable:
2.4 The detection configuration is successful:
cmdCommand Window input to view the version of the Go go version go, in the input go env can view all the environment configuration information, focusing on our manual configuration of information:
If you see this information successfully, the configuration is successful!
3. Pycharm to go Plugin
Select File -> Setting... -> Plugins , selectBrowse repositories...
into the plug-In search interface, enter in the input box go , select the second item, Ann turn a bit long, may fail, try more than a few times OK.
4. New Project Test Run
Be sure to GOPATH create a new project, the process and other programs are the same, not repeat, in the Setting... configuration GO of the SDK path:
New Go file: hello.go , Edit code:
package mainimport "fmt"func main(){ fmt.Printf("hello world\n")}
Compile and run: right-clickRun 'go run hello.go'
Congratulations on the Go Programming journey, Happy coding!