Skip to content

hazmee007/vscode-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go for Visual Studio Code

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

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

For bug reports and/or feedback, email lukeh or open a bug under the Monaco\Go area path.

Using

First, you will need to install a dogfood build of Visual Studio Code, for example build that includes the commit 2945a564. The builds for the different platforms are available here and you have to search for the build with the desired commit.

Note: Once you’ve installed this, you must not accept any automatic updates. If you do, you will be reverted to publicly released builds. Steps for how to opt out of automatic updates can be found here.

Next, clone this repo into your Code extensions folder and run npm install.

cd ~/.vscode/extensions/
git clone https://monacotools.visualstudio.com/DefaultCollection/Monaco/_git/go-code
cd go-code
npm install

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.

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": "Delve test",
			"type": "go",
			"program": "/Users/lukeh/dd/go/src/github.com/lukehoban/azuretest/test.go"
		}
	]
}

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/go-code
cd ~
https://monacotools.visualstudio.com/DefaultCollection/Monaco/_git/go-code
cd go-code
npm install
code . 

To build, use the Tasks: Run Build Task command (cmd-shift-B). This will start a build watcher so that .ts files are compiled on save.

You can now go to the Debug viewlet and select Launch Extension then hit play (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.

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.

  • gorename: go get -u -v golang.org/x/tools/cmd/gorename
  • gocode: go get -u -v github.com/nsf/gocode
  • goreturns: go get -u -v sourcegraph.com/sqs/goreturns
  • 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

And for debugging:

  • delve: go get -u -v github.com/derekparker/delve/cmd/dlv

Demos

IDE Features

IDE

Debugger

IDE

About

Go extension for Visual Studio Code

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 95.4%
  • Go 4.0%
  • Other 0.6%