Considering if launch.json's program attribute resolves to a file in debug mode#3016
Conversation
| request: 'launch', | ||
| mode: 'auto', | ||
| program: '${fileDirname}', | ||
| program: '${file}', |
There was a problem hiding this comment.
I understand this change is based on my comment #1229 (comment)
But I now realize that this change can break the workflow for existing users who might
start debugging from a file that does not have the main function. Having ${fileDirname} ensured that such scenarios are supported.
I recommend we not make this change. Folks wanting to have multiple files with main function in the same folder, can create a debug configuration with ${file} and have the debugging feature work for them
|
@marcel-basel I tested the changes here with the below set up and I see failures
package main
import "fmt"
func main() {
fmt.Println(Bye())
}
package main
func Bye() string {
return "bye"
}
I get the below error: Looks like when we pass a single file to |
|
cc @quoctruong |
|
I discussed with @quoctruong and @jhendrixMSFT offline and it looks like the above behavior matches the |
Fixing #1229
Implemented intial proposal by @ramya-rao-a
When the
programattribute points to a file (${file} or absolute path), the filepath is now passed to the delve debug command. Thus debugging also works if multiple main files exist in the package. Launching debug from active editor file with no main function (Program = ${file}) will result in following error "Can not debug non-main package".Program ${fileDirname} configuration works as before.
Updated the default value for program attribute in goDebugConfiguration.ts file to be {$file} instead of ${fileDirname}
Documentation [https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code] (url) should be updated e.g. first launch.json example. Since I'm not a native English speaker so not the best person to help.