This is a creation in Article, where the information may have evolved or changed.
First, download and install go
The process does not repeat, the next step. The default will be installed, it is C:\GO
recommended not to modify, otherwise, what will happen strange bug.
After installation, you need to configure GOPATH
environment variables, the environment variable directory is the project root directory, mine isD:\code\MCChatServer
Note GOPATH
to capitalize
Second, installation Vscode
Still the next step, after the installation is complete, open the software and install the Vscode go plugin.
Select the 5th option on the left side of the Vscode, enter go in the search bar above, and select the author to install the Lukehoban plugin.
After the installation is complete, restart the Vscode. Then in the project and directory to create a suffix to go file, such as main.go
, open with Vscode, open will automatically eject the installation Go Extension plugin prompt, select install all
Vscode will automatically install the required plug-ins (there are several plugins need to flip the wall)
Or, use the command-line installation in the project directory:
After the installation is complete, create the Settings.json file in the. Vscode folder in the project and directory, and paste the code in the 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": "D:\\code\\MCChatServer", "go.gocodeAutoBuild": false}
go.gopath
the path of attention is consistent with your own.
Three, run it
Write code in Main.go:
package mainimport "fmt"func main() { fmt.Println("Hello, GO")}
Press the F5
run code, this time will pop up no delve error, install one is, use the command line to run:
go get -u -v github.com/derekparker/delve/cmd/dlv
Press again to F5
run.
Well, the environment is here, and the next section starts building the WebSocket server.