Home > other >  Receiving a command line input vscode debugging go program
Receiving a command line input vscode debugging go program

Time:10-23

Learned to go these days, with vscode development tools, in the case of repeat the book, found that many of them are required to receive command line input (OS) Stdin),

Although you can use the go build compiled exe, and then above the terminal of the vscode run, but it can't step through;

Want to ask you is how to solve this problem, or don't have to vscode said?

CodePudding user response:

OS module line

The import "OS"

The args:=OS. The args [1]

CodePudding user response:

Should be I didn't say clear, the input parameters in advance (launch. Json) can indeed by OS. The Args to get, but I is the time to debug the problem of how to dynamically receives input;

Such as written in the go a addition function, from the OS. The Stdin accepts two parameters for together, but when debugging vscode won't pop-up command line interface, where I'm going to enter? Is there any way like vs2010 debug console program, play a CMD when debugging, can let me enter?

CodePudding user response:

R:=bufio NewReader (OS Stdin)
For {
RawLine, _, _ :=r.R eadLine ()
The line: string=(rawLine)
FMT. Println (line)
}
Can understand, it's a cycle input, after the build that can be executed the pop-up box

CodePudding user response:

Thank you for reply, generated by the build exe, and then execute exe can really solve the problem of input, but this can't debugging, this is what I have encountered problems;

Is there to like vs2010 that input when debugging method, for example:

1) start debugging by vscode, automatic popup CMD interface receives input;
2) the program detects input, trigger breakpoints, can then step through data processing logic;

CodePudding user response:

So in the end, you have find a way to solve the problem of unable to enter? I also encountered the same difficulties with you

CodePudding user response:

The solution? The eldest brother
  • Related