Skip to content

Commit 404e847

Browse files
committed
Merge remote-tracking branch 'vso/0.9'
2 parents 89db678 + 4c8bfad commit 404e847

28 files changed

+6496
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
out
2+
node_modules

.vscode/launch.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"name": "Launch Extension",
6+
"type": "extensionHost",
7+
// path to VSCode executable
8+
"runtimeExecutable": "${execPath}",
9+
// force VSCode to create a new window and pass this project as an additonal plugin location
10+
// add workspace path to %GOPATH% so that there is some meaningful contents
11+
"args": [ "--new-window", "--extensionDevelopmentPath=${workspaceRoot}" ],
12+
"stopOnEntry": false,
13+
"sourceMaps": true,
14+
"outDir": "out"
15+
},
16+
{
17+
"name": "debug-debugger",
18+
"type": "node",
19+
"program": "./out/debugAdapter/goDebug.js",
20+
"stopOnEntry": false,
21+
"args": [ "--server=4711" ],
22+
"sourceMaps": true,
23+
"outDir": "out/debugAdapter"
24+
}
25+
]
26+
}

.vscode/settings.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": true,
5+
"typings": false
6+
},
7+
"search.exclude": {
8+
"**/node_modules": true,
9+
"**/bower_components": true,
10+
"out/": true
11+
}
12+
}

.vscode/tasks.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Available variables which can be used inside of strings.
2+
// ${workspaceRoot}: the root folder of the team
3+
// ${file}: the current opened file
4+
// ${fileBasename}: the current opened file's basename
5+
// ${fileDirname}: the current opened file's dirname
6+
// ${fileExtname}: the current opened file's extension
7+
// ${cwd}: the current working directory of the spawned process
8+
9+
// A task runner that calls the Typescript compiler (tsc) and
10+
// compiles the extension.
11+
{
12+
"version": "0.1.0",
13+
14+
// The command is tsc. Assumes that tsc 1.5.x or higher has been installed using npm install -g typescript
15+
"command": "node_modules/.bin/tsc",
16+
17+
// The command is a shell script
18+
"isShellCommand": true,
19+
20+
// Show the output window only if unrecognized errors occur.
21+
"showOutput": "silent",
22+
23+
// args is the HelloWorld program to compile.
24+
"args": ["-w"],
25+
26+
// use the standard tsc problem matcher to find compile problems
27+
// in the output.
28+
"problemMatcher": "$tsc"
29+
}

README.md

+99-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,99 @@
1-
# vscode-go
2-
An extension for VS Code with provides support for the Go language.
1+
# Go for Visual Studio Code
2+
3+
This Code extension adds rich language support for the Go language, including:
4+
5+
- Colorization
6+
- Completion Lists (using `gocode`)
7+
- Snippets
8+
- Quick Info (using `godef`)
9+
- Goto Definition (using `godef`)
10+
- Find References (using `go-find-references`)
11+
- File outline (using `go-outline`)
12+
- Rename (using `gorename`)
13+
- Build-on-save (using `go build` and `go test`)
14+
- Format (using `goreturns` or `goimports` or `gofmt`)
15+
- [partially implemented] Debugging (using `delve`)
16+
17+
For bug reports and/or feedback, email `lukeh` or [open a bug ](https://monacotools.visualstudio.com/DefaultCollection/Monaco/_workItems#_a=new&witd=Bug&%5BSystem.Title%5D=Go%3A&%5BSystem.AreaPath%5D=Monaco%5CGo) under the `Monaco\Go` area path.
18+
19+
## Using
20+
21+
First, you will need to install Visual Studio Code 0.9.*.
22+
23+
Next, clone this repo into your Code extensions folder and run `npm install`.
24+
25+
```bash
26+
cd ~/.vscode/extensions/
27+
git clone https://monacotools.visualstudio.com/DefaultCollection/Monaco/_git/go-code
28+
cd go-code
29+
npm install
30+
```
31+
32+
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.
33+
34+
### _Optional_: Debugging
35+
36+
To use the debugger, you must currently manually install `delve`. See the [Installation Instructions](https://github.com/derekparker/delve/wiki/Building) 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.
37+
38+
Once this is installed, go to the Code debug viewlet and select the configuration gear, placing the following in your launch.json:
39+
40+
```json
41+
{
42+
"version": "0.1.0",
43+
"configurations": [
44+
{
45+
"name": "Delve test",
46+
"type": "go",
47+
"program": "/Users/lukeh/dd/go/src/github.com/lukehoban/azuretest/test.go"
48+
}
49+
]
50+
}
51+
```
52+
53+
## Building and Debugging the Extension
54+
55+
You can set up a development environment for debugging the extension during extension development.
56+
57+
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.
58+
59+
```bash
60+
rm -rf ~/.vscode/extensions/go-code
61+
cd ~
62+
git clone https://monacotools.visualstudio.com/DefaultCollection/Monaco/_git/go-code
63+
cd go-code
64+
npm install
65+
code .
66+
```
67+
68+
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.
69+
70+
You can now go to the Debug viewlet and select `Launch Extension` then hit play (`F5`).
71+
72+
In the `[Extension Development Host]` instance, open your GOPATH folder.
73+
74+
You can now hit breakpoints and step through the extension.
75+
76+
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.
77+
78+
## Tools
79+
80+
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.
81+
82+
- gorename: `go get -u -v golang.org/x/tools/cmd/gorename`
83+
- gocode: `go get -u -v github.com/nsf/gocode`
84+
- goreturns: `go get -u -v sourcegraph.com/sqs/goreturns`
85+
- godef: `go get -u -v github.com/rogpeppe/godef`
86+
- golint: `go get -u -v github.com/golang/lint/golint`
87+
- go-find-references: `go get -u -v github.com/lukehoban/go-find-references`
88+
89+
And for debugging:
90+
91+
- delve: `go get -u -v github.com/derekparker/delve/cmd/dlv`
92+
93+
## Demos
94+
95+
### IDE Features
96+
![IDE](http://i.giphy.com/xTiTndDHV3GeIy6aNa.gif)
97+
98+
### Debugger
99+
![IDE](http://i.giphy.com/3oEduO9Rx6awkds4es.gif)

package.json

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "go-code",
3+
"version": "1.0.0",
4+
"publisher": "lukehoban",
5+
"description": "Go support for Visual Studio Code",
6+
"author": {
7+
"name": "Microsoft Corporation"
8+
},
9+
"private": true,
10+
"repository": {
11+
"type": "git",
12+
"url": "https://monacotools.visualstudio.com/DefaultCollection/Monaco/_git/go-code"
13+
},
14+
"scripts": {
15+
"prepublish": "tsc"
16+
},
17+
"extensionDependencies": [
18+
"vscode.go"
19+
],
20+
"dependencies": {
21+
"json-rpc2": "^1.0.2"
22+
},
23+
"devDependencies": {
24+
"typescript": "^1.6.2"
25+
},
26+
"engines": {
27+
"vscode": "*"
28+
},
29+
"activationEvents": [
30+
"onLanguage:go"
31+
],
32+
"main": "./out/goMain",
33+
"contributes": {
34+
"languages":
35+
[{
36+
"id": "go",
37+
"extensions": [
38+
".go"
39+
],
40+
"aliases": [
41+
"Go"
42+
]
43+
}
44+
],
45+
"debugAdapter": [
46+
{
47+
"type": "go",
48+
"enableBreakpointsFor": {
49+
"languageIds": [
50+
"go"
51+
]
52+
},
53+
"program": "./out/debugAdapter/goDebug.js",
54+
"runtime": "node"
55+
}
56+
],
57+
"configuration": {
58+
"type": "object",
59+
"title": "Go configuration",
60+
"properties": {
61+
"go.buildOnSave": {
62+
"type": "boolean",
63+
"default": true,
64+
"description": "Run 'go build'/'go test' on save."
65+
},
66+
"go.lintOnSave": {
67+
"type": "boolean",
68+
"default": true,
69+
"description": "Run 'golint' on save."
70+
},
71+
"go.vetOnSave": {
72+
"type": "boolean",
73+
"default": true,
74+
"description": "Run 'go tool vet' on save."
75+
},
76+
"go.formatTool": {
77+
"type": "string",
78+
"default": "goreturns",
79+
"description": "Pick 'gofmt', 'goimports' or 'goreturns' to run on format."
80+
},
81+
"go.gopath": {
82+
"type": "string",
83+
"default": null,
84+
"description": "Specifies the GOPATH to use when no environment variable is set."
85+
}
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)