Reputation: 531
I am having difficulty in passing command-line arguments in VSCode (debug mode) with golang.
Below is the small code example and the launch.json:
package main
import (
"flag"
"fmt"
)
func main() {
flag1Ptr := flag.Bool("flag1", false, "flag1 is a flag")
flag.Parse()
fmt.Println(*flag1Ptr)
fmt.Println("Hello, world")
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": [
"-flag1"
]
}
]
}
The output is always "false" for *flag1Ptr but it should be "true".
Update: The issue disappeared after closing down VSCode and reopening it (I am on a Mac(osX))
Upvotes: 43
Views: 40510
Reputation: 11
For me just adding launch.json to .vscode worked but not with Run Current File or Node.js options in RUN AND DEBUG menu, I needed to use Launch Program and it worked
Upvotes: 0
Reputation: 561
list all params, for example, command is:
"hello.exe -in InfoEntity.java -out aa.out"
the debug config is:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": ["-in", "InfoEntity.java", "-out", "aa.out"]
}
]
}
Upvotes: 50