Go extension for Visual Studio Code
Перейти к файлу
netroby 5587b3d556 Update readme, put install deps all together 2015-11-20 06:58:22 +08:00
.vscode Add instructions for debugger the debugger 2015-11-06 16:52:12 -08:00
images Update gallery image and background 2015-11-15 16:47:59 -08:00
snippets updated to the latest 2015-09-15 17:28:31 +02:00
src Merge branch 'master' of https://github.com/microsoft/vscode-go 2015-11-19 11:22:34 -08:00
syntaxes updated to the latest 2015-09-15 17:28:31 +02:00
test fixed broken test 2015-11-06 16:24:05 +01:00
typings Avoid manual tweaking of the fs-extra.d.ts 2015-10-30 09:15:42 +01:00
.gitignore Update README and enable `npm install` for installation. 2015-09-21 21:36:53 -07:00
.vscodeignore First test 2015-10-29 22:31:21 +01:00
LICENSE Add LICENSE 2015-10-14 12:15:13 -07:00
README.md Update readme, put install deps all together 2015-11-20 06:58:22 +08:00
package.json Update the devDepencencies and add typescript 2015-11-19 12:18:47 -05:00
thirdpartynotices.txt Add a thirdpartynotices.txt 2015-11-17 22:39:19 -08:00
tsconfig.json More updates to development setup. Added the noLib=true to tsconfig.json so that the vscode setup can control the .d.ts files that are used. 2015-10-21 08:42:56 +02:00

README.md

Go for Visual Studio Code

This extension adds rich language support for the Go language to VS Code, including:

  • Colorization
  • Completion Lists (using gocode)
  • Snippets
  • Quick Info (using godef)
  • Goto Definition (using godef)
  • Find References (using go-find-references)
  • File outline (using go-outline)
  • Rename (using gorename)
  • Build-on-save (using go build and go test)
  • Format (using goreturns or goimports or gofmt)
  • [partially implemented] Debugging (using delve)

IDE Features

IDE

Debugger

IDE

Using

First, you will need to install Visual Studio Code 0.10. In the command palette (cmd-shift-p) select Install Extension and choose Go.

In a terminal window with the GOPATH environment variable set to the GOPATH you want to work on, launch code. Open you GOPATH folder or any subfolder you want to work on, then open a .go file to start editing.

Note: It is strongly encouraged to turn Auto Save on in Visual Studio Code (File -> Auto Save) when using this extension. Many of the Go tools work only on saved files, and error reporting will be more interactive with Auto Save turned on.

Options

The following Visual Studio Code settings are available for the Go extension. These can be set in user preferences (cmd+,) or workspace settings (.vscode/settings.json).

{
	"go.buildOnSave": true,
	"go.lintOnSave": true,
	"go.vetOnSave": true,
	"go.formatTool": "goreturns",
	"go.gopath": "/Users/lukeh/go"
}

Optional: Debugging

To use the debugger, you must currently manually install delve. See the Installation Instructions for full details. This is not yet supported on Windows, and on OS X it requires creating a self-signed cert to sign the dlv binary.

Once this is installed, go to the Code debug viewlet and select the configuration gear, placing the following in your launch.json:

{
	"version": "0.1.0",
	"configurations": [
		{
			"name": "Launch main.go",
			"type": "go",
			"request": "launch",
			"program": "main.go",
			"stopOnEntry": false,
			"env": {},
			"args": [],
			"cwd": "."
		}
	]
}

Building and Debugging the Extension

You can set up a development environment for debugging the extension during extension development.

First make sure you do not have the extension installed in ~/.vscode/extensions. Then clone the repo somewhere else on your machine, run npm install and open a development instance of Code.

rm -rf ~/.vscode/extensions/lukehoban.Go
cd ~
git clone https://github.com/Microsoft/vscode-go
cd vscode-go
npm install
code . 

You can now go to the Debug viewlet and select Launch Extension then hit run (F5).

In the [Extension Development Host] instance, open your GOPATH folder.

You can now hit breakpoints and step through the extension.

If you make edits in the extension .ts files, just reload (cmd-r) the [Extension Development Host] instance of Code to load in the new extension code. The debugging instance will automatically reattach.

To debug the debugger, see the debugAdapter readme.

Tools

The extension uses the following tools, installed in the current GOPATH. If any tools are missing, the extension will offer to install them for you.

  • gocode: go get -u -v github.com/nsf/gocode
  • godef: go get -u -v github.com/rogpeppe/godef
  • golint: go get -u -v github.com/golang/lint/golint
  • go-find-references: go get -u -v github.com/lukehoban/go-find-references
  • goreturns: go get -u -v sourcegraph.com/sqs/goreturns
  • gorename: go get -u -v golang.org/x/tools/cmd/gorename

To install them just paste and run

go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename

And for debugging:

License

MIT