microsoft / vscode-go Goto Github PK
View Code? Open in Web Editor NEWAn extension for VS Code which provides support for the Go language. We have moved to https://github.com/golang/vscode-go
License: Other
An extension for VS Code which provides support for the Go language. We have moved to https://github.com/golang/vscode-go
License: Other
HI I have download latest version of GO, Code and vscode-go and installed it in my machine windows 10.
Here is the my user settings file.
{
"editor.fontFamily": "Consolas",
"editor.fontSize": 20,
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.formatTool": "goreturns",
"go.gopath": "F:\Data\Projects\GO\src"
}
and this is my go environment.
Now I have setup 3 folders in my go directory like following as we are doing for each go project.
I have downloaded the all the package of go to make all the things working in go code extension. You can specially gocode and godef is already installed and available.
The project I have opened under "F:\Data\Projects\GO\src\MyWebApp" folder where its a simple web app created in go . But whenever I tried to modify I am getting error
golint is not installed like following.
But if you see in above screenshots golint is already there. So am I doing anything wrong here or is there a bug in vscode. Please help me resolve this issue. This setup works fine with other editors like intellij idea or webstorm. I am getting error in vs code only.
Please suggest what's need to be there. Any help will be appreciated.
VS Code has API to provide parameter hints/signature help. It would be great to also have parameter hints for Go.
I understand golang currently doesn't support creating dll's.
I must comment the courage it took for Microsoft to open source to Visual Studio.
This might be a feature request but I didn't figure out how to change the launch.json config to start dlv test and debug my test suite instead of my actual code. This is very useful when writing Go libs.
I could not get it working for any go project so far.
Repro:
git clone https://github.com/ahmetalpbalkan/wagl.git $HOME/gopath-wagl/src/github.com/ahmetalpbalkan/wagl
export GOPATH=$HOME/gopath-wagl
cd $HOME/gopath-wagl/src/github.com/ahmetalpbalkan/wagl
export GO15VENDOREXPERIMENT=1
code .
then โT
, type stuff, no results.
would make debugging much smoother is the debug console window was scrollable horizontally.
in a code window its nice that i can scroll easily to see long longs.
If there is a way to maybe force the debug console window to flow onto the next line that would be also good.
From @andrewrgoss on November 20, 2015 19:22
Is there a way to turn off the [Info] pop ups that queue up while writing code in VSCode? I have to manually click to close them and I don't want them appearing while writing new code. It's driving me nuts! Tried Googling the topic and couldn't find anything.
Copied from original issue: microsoft/vscode#374
The logic for determining whether all tools are available is not taking into account that GOPATH may contain multiple workspaces.
See discussion in #10.
I've been trying to install the plugin and not having any success, every time I start writing anything I see notifications like:
The 'gocode' command is not available. Use 'go get -u github.com/nsf/gocode' to install.
and all the other tools it needs too. Even those these tools are in fact installed.
I've verified $GOPATH/bin is in my $PATH and I'm running on Go 1.5.1 installed with brew.
Coming from working with Go in sublime I'm used to a workflow where every save runs go fmt. In my particular case, I also have save on loss of focus (but seems like VSCode's autosave fulfills this). That way if I switch to a terminal it is saved before I do something in the terminal.
I use this workflow in two main different ways I can think of now:
So fmt as a commit hook is later than I would like in the workflow I'm used to. Is it possible to get the fmt on save workflow in VSCode as it stands? If not maybe this could be a feature? Or do you think I'm just "doing it wrong"?.
I've also seen this come up in /r/golang and it was a comment on the recent HN post: 'Awesome! Last time I tried VSC it had no gofmt-on-save functionality which I consider mandatory. Now that it does have that and much more, I'm very much looking forward to trying it again.'
my environment is Mac OS X and I have already signed dlv, when i click the build button, the debug console shows
2015/11/22 01:52:35 debugger.go:56: launching process with args: [./debug]
could not launch process: could not fork/exec
my launch.json is
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch main.go",
"type": "go",
"request": "launch",
"program": "main.go",
"stopOnEntry": false,
"env": {},
"args": [],
"cwd": "."
}
]
}
I have everything setup correctly, as far as I can tell. Dlv is installed correctly, it runs it from the command line.
I run the app via the debugger and see the tools (run/pause, step, etc), but nothing happens, no breakpoints hit.
How can I see what's going wrong?
Like typing
<html>
and pressing enter should auto format and add the closing tag </html>
Pressing 'ctrl+.' 'ctrl+p' will show import package list.
It's easy to filter packags which want to import with key words.
So we don't need to remember the full path for packags.
There are a number of things to do here:
ThreadEvent
s so that threads window is accurate (microsoft/vscode#40) (e51037a)I can
sudo dlv debug main.go
But no dice from VSCode. Any thoughts?
I did code sign dlv and all the dlv tools work as running sudo
When using a main.go with a very simple 3 line program which outputs a string to stdout, a breakpoint can be set, but when running, the only feedback I get is that the debug bar shows and appears to be running, but the breakpoint isn't fired and the blue bar at the bottom of Code turns to orange.
In order to provide support for dependency management tools like gb it's necessary to support colon-seperated GOPATH like this:
/home/foo/gotools:/home/foo/dev/myproject:/home/foo/dev/myproject/vendor
The Go tools are working correctly with this kind of GOPATH, but vscode-go seems to be confused (since it's simply ignoring this GOPATH).
I have an interface with a method on it.
That method is called in another file.
I have several files that implement or conform to that interface which have the method in them.
Should Find References show those implementations or only those where its called and defined like it does currently?
I would like to contribute and fix some of the issues but since this is a Microsoft project is there anything I need to be made aware of?
Code could be a little more consistent in style. Sometimes strings are single quoted, other times double quoted. Sometimes properties are accessed like process.env["GOPATH"]
, other times process.env.GOPATH
.
Willing to help in any way I can to make this more awesome.
I've been working a fair bit with the plugin today and have noticed that the format code command sometimes corrupts my imports. I use "goimports" as my formatter. I've been using this for months with vim-go so I don't think it is the fault directly of goimports.
For example, I got this import
import (
"encoding/jsonfmtio/ioutil"
)
which should have been:
import (
"encoding/json"
"fmt"
"io/ioutil"
)
Currently, Go tools are located and acquired based on the currently active GOPATH. This has a few downsides:
Instead, the plugin could automatically install these to it's own private GOPATH and use the binaries from that location. This could also allow the plugin to control versioning of these tools more precisely.
Additional feedback from offline discussion:
So if the plugin could grab them and everything just works out of the box with all these things installed, it actually might be pretty cool. It can also manage updates for those tools in a centralized place, rather than having them compiled at $GOPATH/bin of 10 different projects and eventually getting out of date independently.
Thoughts?
The Oracle tool provides a number of features which would be nice to expose in Code, including at least:
These may be good candidates for exposing via CodeLens as well as through editor commands.
The gopath seems to be correctly set because typing errors ('Undefined: ...') en vet messages ('exported function should have comment') are reported correctly.
However, the formatting is not corrected ? Not on disk and not in the editor. I tried to override the default goreturns with goimports and then with gofmt, but that does not seems to matter.
Any ideas ?
Pressing 'ctrl+.' 'ctrl+p' will show import package list.
It's easy to filter packags which want to import with key words.
So we don't need to remember the full path for packags.
The current description says "An extension for VS Code with provides support for the Go language."
I don't think its suppose to be "with" but rather "which".
It should read "An extension for VS Code which provides support for the Go language."
To reproduce:
Create two empty files: main.go
and second.go
.
Launch vscode and open main.go
Make main.go
a minimally valid go program, e.g.:
package main
func main() {
}
main.go
What happens: we get an error: "expected 'package', found 'EOF' in main(1,1)"
.
What should happen: the error message is correct but the error is in second.go
(empty) file, not main.go
. It looks like all errors are attributed to file that was saved (and triggered error check), not necessarily the file that contains an error.
From @Totoajax on November 20, 2015 17:9
Since the new update (0.10.1) my Macbook Airs fan sounds like a jet engine!!! If this isn't a bug, please make an option to disable some of the new things to make it quiet again. I REALY REALY loves Visual Code, so please fix this!
Copied from original issue: microsoft/vscode#364
Currently debugging silently fails when Delve is not installed. Since Delve requires somewhat complex installation at least on OS X we cannot install it automatically for the user, but we should identify when it is missing and provide guidance on installing it.
Just asking, because I recently moved from Atom
and the go package made specifically for it does:
unused
one)If answer to any of these questions is Not yet
, I am happy to contribute. It's quite a deal breaker for me, since after working with Atom for a couple of weeks I constantly forget about jumping onto the beginning of the file and editing that import section.
Thanks! Apart from that, all works pretty well, really happy with the autocompletion & hints.
The debugger is searched in by concat the GOPATH and bin/dlv
.
https://github.com/Microsoft/vscode-go/blob/master/src/debugAdapter/goDebug.ts#L109
As the other tools are now searched in the PATH
or in the GOPATH
it would be great to search dlv
in the same way.
On OS X 11.11.1, most of the Go commands seem to be working, however Go Build
on save does not work.
Go Path seems to be correct.
Open the quick outline and jump to a symbol. Notice that the character position is off-by-one.
Following the building and debugging instructions, when I open go source files in the Exntesion Development Host I get this:
Activating extension `lukehoban.Go` failed: Cannot find module '/Users/jonathan/vscode-go/out/src/goMain'
Here is the error stack: Error: Cannot find module '/Users/jonathan/vscode-go/out/src/goMain'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.n._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/pluginHostProcess.js:18:17333)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Function.t [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:5:1298)
at u (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/pluginHostProcess.js:12:20550)
at t._loadPluginModule (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/pluginHostProcess.js:12:24382)
at t.e._actualActivatePlugin (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/pluginHostProcess.js:11:29061)
at t._actualActivatePlugin (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/pluginHostProcess.js:12:24874)
Currently, Metalinter is extremely useful linter.
Go Vet, Go Lint and other highly useful tools are included
As it provides massaged output of composite linters, is it possible to use it as (optional) replacement/enchancement for aforementioned Vet and Lint tools?
Using the instructions provided in the readme, I have installed the delve debugger on Mac and create a launch.json as in the example. However, when I start the debugging on a (working) application, nothing happens. The statusbar turns orange, but no breakpoints are hit, no output is generated. I don't get any errors, also not in the console of the developer tools.
I've updated the plugin to the latest version yesterday evening. Any advice on how to find out what exactly my problem is?
(Other than the issue I have above, my experience so far is very positive. Nice work!)
My gomode plugin for go-sublime has support for "on the fly compilation". Namely, the gocode is compiled as I type which is super useful.
https://github.com/newhook/gomode
It would be really cool if something like this could work with this plugin.
Please add support for the gometalinter (https://github.com/alecthomas/gometalinter). Also make it configurable as far as possible
Would be very helpful and I can throw my terminal/console/shell away :)
I have my
"go.formatTool": "gofmt"
but when I try to press alt+shift+f
I get:
The 'goreturns' command is not available. Use 'go get -u sourcegraph.com/sqs/goreturns' to install.
running on Mac OS X, it doesn't seem to be trying to use my setting unless alt-shift-f
is strictly bound to goreturns, I can't find the keybindings anywhere. Thanks.
I added a fmt.Println()
to a file, which should have added "fmt" to the imports. When I right-clicked "Format Code" it did this instead:
import (fmt"io/ioutil"
"log"
"os"
"os/signal"
"syscall"
)
and kind of mashed the "fmt" improperly into the beginning of the list.
Did I do it wrong? ๐ Also, can it run gofmt on save?
If you use the rename functionality then press CMD+Z nothing happens
I get the message that the analysis tools are missing but they are certainly not; the first time I used the extension I got this message and chose Install and some missing tools were installed. The extension seems to work fine with the go analysis tools. After restarting Code, however, it's again complaining about the analysis tools. Am I missing something here?
Please advice.
On Windows, gocode.exe continues to run even after VS code is completely closed. I am not sure of the behavior on other platforms. Is there a way to automatically close gocode.exe when the editor itself is exited?
When I select "install analysis tools" it does nothing. I think the issue is
var p = cp.exec("go get -u -v " + tool, { cwd: process.env['GOPATH'], env: process.env });
In my case GOPATH is multi-path, therefore the cwd is invalid when running go get -u ... In this case, couldn't the cwd be left empty? Or perhaps set to the home dir if empty isn't desirable for some reason?
When I debug my go program, I want to change workdir and pass some args to program and modify launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch main.go",
"type": "go",
"request": "launch",
"program": "main.go",
"stopOnEntry": false,
"env": {},
"args": ["../sample"],
"cwd": "build"
}
]
}
and start debugging. But I couldn't find args is passed to it and its' work dir was different from I specified. I run ps aux|grep myprogram
and got
yuntan 9879 18.5 0.3 383580 27368 ? Sl 12:19 0:01 /home/yuntan/Workspace/go/bin/dlv debug --headless=true --listen=127.0.0.1:2345 --log /home/yuntan/Workspace/go/src/github.com/passto/myprogram/main.go
yuntan 9941 0.0 0.1 201576 11940 ? tl 12:19 0:00 ./debug /home/yuntan/Workspace/go/src/github.com/passto/myprogram/main.go
It seems debug
is debug binary of my program built by delve and vscode passes invalid argument. When I run dlv debug -- somearg
in project dir and run ps aux|grep somearg
I got
yuntan 14269 1.2 0.3 505404 31268 pts/4 Sl+ 12:25 0:00 dlv debug -- somearg
yuntan 14329 0.0 0.1 137356 10996 pts/4 Sl 12:26 0:00 ./debug somearg
argument I specified is passed to debug
binary.
VS Code 0.10.1 Go Extension 0.6.7 on Linux
Hi here,
not sure it is an issue, probably more a question.
Where is the stdout console ? where we can see all the log.Print...
The logs are not in the terminal that launched VSCode
I'm on MacOSX.
Thanks
Jerome
In the Go extension package.json, categories "Languages", "Linters", and "Snippets" are called out but not "Debuggers" even though it contributes to the debuggers extension point.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.