This is a creation in Article, where the information may have evolved or changed.
Install Go
(1) Download go installer download address: https://golang.org/dl/(in-Wall download address http://www.golangtc.com/download), if your system is a windows32-bit system, Please choose Go1.6.2.windows-386.msi, if you want to install go1.7beta2,1.7 official version to be released on August 1
(2) After download directly double-click MSI file installation, installed by default in C:\go
(3) After the installation is complete, the environment variable Path is added to the bin directory under the Go installation directory C:\Go\bin\, and the environment variable goroot is added, and the value is the Go install root directory C:\Go\
(4). Verify that the installation is successful, enter CMD in the Run Open command line tool, enter go at the prompt
(5) Set Workspace Gopath directory (project path for Go language development)
Windows settings are as follows, a new environment variable name is called Gopath, and the value is your working directory, such as the author's settings Gopath=e:\mygo
The above%gopath% directory Convention has three subdirectories:
SRC store source code (e.g.,. Go. C. h, etc.)
The files generated by the PKG after compilation (for example:. a)
Executable file generated after bin compilation (for convenience, you can add this directory to the path variable in Windows and append%gopath%\bin to the environment variable path)
(6) Use the Go ENV command to view environment variable settings
Install vs code and Golang plugins
Download Install vs Code
Download Address https://code.visualstudio.com/, and then select download for Windows
Install the Go plugin
VS Code provides developers with a lot of plug-ins to get vs code to better write go code, need to install the Golang plugin
(1) Start vs code
(2) Ctrl+shift+p Open the command panel, enter install at the cursor, and select Install extension from the drop-down list
Then wait for VS code to get the plug-in list from the remote server and choose the Go plugin installation
Third-party packages required to install the Go plugin
For the Golang plug-in to implement the syntax smart hints, debug, etc., must install some third-party packages, install the third package in two ways, one is to let the software automatically installed, one is manually installed
(1) The first way
Create a new Hello.go file under the E:\MYGO\SRC directory with the following code
package mainimport "fmt"func main() { fmt.Println("Hello, 世界")}
Then open the file with VS code and we'll see that analysis Tools Missingappears in the lower-right corner of VS code, click to help us install all of the third-party packages required for this plugin
Note that you need to download the Gorename package (Golang.org/x/tools/cmd/gorename) and the Guru package (Golang.org/x/tools/cmd/guru) during the installation process, you need to flip the wall, or you cannot download the installation.
Children's shoes that do not turn over the wall please go to its github image to download the ZIP package [mirror] Go Tools https://godoc.org/golang.org/x/tools
Unzip the files in the zip to the E:\mygo\src\golang.org\x\tools directory
Then hold down the SHIFT key in this directory and right-click, choose to open the command line here, and then enter go install at the command prompt
(2) Second way, manual installation
Open a command line prompt and paste the following command
go get -u -v github.com/nsf/gocodego get -u -v github.com/rogpeppe/godefgo get -u -v github.com/golang/lint/golintgo get -u -v github.com/lukehoban/go-outlinego get -u -v sourcegraph.com/sqs/goreturnsgo get -u -v golang.org/x/tools/cmd/gorenamego get -u -v github.com/tpng/gopkgsgo get -u -v github.com/newhook/go-symbolsgo get -u -v golang.org/x/tools/cmd/guru
Also need to turn over the wall when acquiring Gorename and guru, the solution is as above
- VS Code Configuration
Start vs Code after selecting File menu-"preferences-" Workspace settings
Paste the following code in the open Settings.json file
{ "go.buildOnSave": true, "go.lintOnSave": true, "go.vetOnSave": true, "go.buildTags": "", "go.buildFlags": [], "go.lintFlags": [], "go.vetFlags": [], "go.coverOnSave": false, "go.useCodeSnippetsOnFunctionSuggest": false, "go.formatOnSave": true, "go.formatTool": "goreturns", "go.goroot": "C:\\Go", "go.gopath": "e:\\mygo", "go.gocodeAutoBuild": false}
As shown
Restart to enable vs Code Fly general write go code
Installing the Vscode-icons Plugin
Vscode-icons plug-ins, you can provide the corresponding icons for different file types in Vscode, such as
Installation method
Open Vscode Press F1 to bring up the command panel, and then perform the Ext install vscode-icons installation
Enable plugins
Run Vscode as administrator (right-click Vscode and select Run as Administrator), then press F1 to bring up the command panel and execute the command Icons enable plug-ins
Plug-in failure resolution method
Vscode update will cause the plugin to become invalid, run Vscode as an administrator, then press F1 to bring up the command panel and execute icons update
Install Git version control
VS code1.2 added support for version control Git, which can be used for code submission, pull, merge, etc.
To use Git versioning on the Windows platform, we have to install git ourselves first
Access https://git-for-windows.github.io/Download Installation
(1) Visit githubhttps://github.com/registered account, GitHub mainly as our remote warehouse, the local code submitted to the above, the registration of the email and username to be filled in with our local git configuration in the same email and user name
(2) Find a git program from the Start menu to open git bash
And then enter
$ git config --global user.name "Your Name" $ git config --global user.email "email@example.com"
Note Replace the above your name and email@example.com with the username and email you registered on GitHub
Using Git version control
- Initializing the Repository
Enter the working directory you need to initialize, such as I want to set up the WeChat directory all the files to build the repository, then in Git bash into the WeChat directory, and then execute
Git init
- Add all files to staging area and execute them under Git bash
git Add.
- Submit to local Warehouse
git commit-m "Submit Comment description"
- New Remote Warehouse
Login https://github.com/Create a new empty remote repository WeChat
Select New Repository
- Associating a local warehouse with a remote warehouse
Enter in the Git bash interface
Git remote add Origin git@github.com:puma007/wechat.git
- Push Updates
To push local code to the remote repository
Git push-u Origin Master