Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Debug: add "go run ." support #3096

@chapati

Description

@chapati

After changes made in the issue #2085 'Start without debugging' always defaults to the current go file. The rationale behind the change was the following:

Debug: Start without Debugging is the command to use to simply run the current file rather than debugging.

Let's consider the following program.

main. go

package main
func main () {
second()
}

second.go
package main
func second() {
}

If you open main.go in your active editor and Ctrl+F5 you would get 'undefined: second'
If you open second.go in your active editor and Ctrl+F5 you would get 'runtime.main_main·f: function main is undeclared in the main package'

While I agree that cmd should not start debugging I do not see any reasons why I'm unable to 'just run' the program that has several go files. Currently I'm forced to debug, i.e. switch to the debug view, stop at each breakpoint, switch back to the editor when debug is finished, while in 90% of cases I just want to run, check output and continue editing.

The current behaviour is pretty useless. It works only for programs that have only one file with the main in it. This is pretty rare. It would be much more useful to run the whole package ("go run packagename" or "go run .") and not the current file or at least allow to override the current behaviour from launch.json. Currently this is forced in

https://github.com/microsoft/vscode-go/blob/master/src/goDebugConfiguration.ts

debugConfiguration['currentFile'] = activeEditor && activeEditor.document.languageId === 'go' && activeEditor.document.fileName;

and in https://github.com/microsoft/vscode-go/blob/master/src/debugAdapter/goDebug.ts

and there is no way to run the whole package. Let's add an option to allow running the whole package / execute "go run ." or "go run packagename". Take a look at golang/go#22726 for more details about "go run ."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions