-
Notifications
You must be signed in to change notification settings - Fork 646
Add commands for executing go build
, go test
and go install
#21
Comments
The build on save should report compilation errors as red squiggles and in the bar at the bottom left of the screen. Are you not seeing errors being reported? The build on save does not produce a binary or any other artifact. You can use VS Code's tasks to hook up a build command to run |
If there is an error in the code I see red squiggles, so yes if the code has errors I see them in the IDE. I was under the impression it would generate a binary with Go Build, but your saying that it is working correctly as Build on Save lets you know if there are errors. It would be great if "Go for Visual Studio Code" could include those tasks like Go Build, etc like GoSublime on SublimeText. Off topic, VS Code is fast. It is up there IMO with SublimeText. Thanks, Parag
|
@ppone Makes sense. Let's keep this issue to track adding more integration with There are likely two ways to include these:
The second is more native to VS Code, but likely the first is a convenient shortcut to this. Thoughts? |
The first option I think will the best for users. The beauty of a ideal IDE is that CMD+Shift+P would all of the Go tooling, such that you never need to leave the IDE.
|
go build
, go test
and go install
+1 for first option |
Why not providing the two options ? Some users coming from Sublime Text will find the first option more intuitive, and the second will be more useful for those who master VSCode like pros ! |
@Mistermatt007 Agreed - I think both can be supported. |
How to vote up this feature? |
Question for folks looking for (1). Should |
Maybe when you invoke the command, a second menu should ask you what to build when it's ambigous |
Well it will frequently be ambiguous and I expect a second menu is more friction than is desired in this workflow. Option (2) is also available for full configuration of build/test tasks. My inclination is to go with the active document's folder (even if it is not a .go file). |
I'm the author of GoTools for Sublime and have been evaluating vscode-go. GoTools supports some test related commands I use many times a day and simply can't work without:
You can see how I implement these in the source. Maybe there's something which could save you some time coming up with an equivalent implementation.
The way I handled this in GoTools is to require users to define the package structure on a project basis. I also only support
The latter two are good examples of dealing with the complexity of configuring extremely large Go projects. Related for future reference: anything that requires a package scope (like oracle or Offtopic: Thanks for your work on this plugin, it seems really promising so far, and I'm eager to help out. I think I've hit the limit of what Sublime can be expected to provide with its limited API and UI (especially with Delve.) This project has me thinking about learning TypeScript and redirecting my efforts... |
@ironcladlou Thanks for weighing in here. Definitely agree on the additional commands for running tests - those make sense and happy to take a look at the implementations in GoTools for inspiration. I had hoped to keep the project configuration requirements light here, and rely mostly on the workspace as the context for "global" operations (like find-all-references). But it sounds like you have experience with cases where that is not practical. I'm curious why more of this can't be automatically discovered within a workspace context though ( I also wonder whether (to the extent that additional project configuration is needed) these things should be configured at the workspace settings level, tasks level, or really need a new project file (akin to Do you think it's possible to have smart defaults without any of this additional configuration and then allow this configuration to override those defaults? |
I'm not sure smart defaults are possible with minimal effort - for instance, setting |
You can certainly use wildcards with Tests: Running all tests with wildcards takes too long when working on a single test. Thoughts on the other test variants:
Builds: Running
I'm pretty sure conventions/inference can get us very far with the test executions, but I haven't yet thought of a way to solve the build issues other than allowing the user to specify a list of packages to build. Perhaps |
It seems like I could implement Still trying to wrap my head around VSCode tasks and internals... |
It would be useful also add |
Can't wait until the new features are added. |
Any ETA on this functionality to be available in the stable? |
I was messing around tonight to see if I could get tasks working for |
@ironcladlou I am seeing that the You can force the GOPATH setting with something like this: {
"version": "0.1.0",
"command": "go",
"isShellCommand": true,
"showOutput": "silent",
"options": {
"env": {
"GOPATH": "/Users/lukeh/dd/go"
}
},
"tasks": [
{
"taskName": "install",
"args": [ "-v", "./..."],
"isBuildCommand": true
},
{
"taskName": "test",
"args": [ "-v", "./..."],
"isTestCommand": true
}
]
} |
Added a note about the path forward for this here: #134 (comment). |
@ironcladlou Agreed, I'll go ahead and close this. Feel free to open a new issue for build, or else it can just be a presumed feature of adding |
... and another issue for |
Is there some testing need not met by the existing |
Sorry, didn't know
|
To build package on current opened file path, add this build task:
|
@covrom I tried to change to current opened file's directory several times. I had considered cwd is readonly. |
Installing 8 tools at D:\code\wcy\mygo\bin Installing github.com/ramya-rao-a/go-outline FAILED |
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.
The text was updated successfully, but these errors were encountered: