How to wait for user input? #31

Closed
opened 2023-01-18 12:36:59 +03:00 by da-the-dev · 2 comments
da-the-dev commented 2023-01-18 12:36:59 +03:00 (Migrated from github.com)

I'm learning go and I write simple standard i/o programs. Here's some code:

package main

import (
	"fmt"
	"math"
	"bufio"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

*	var repeatAmount int
	fmt.Fscanf(reader, "%d\n", &repeatAmount)

	for i := 0; i < repeatAmount; i++ {
		var numberOfProgs int
		fmt.Fscanf(reader, "%d\n", &numberOfProgs)
. . .

I use lunarvim, which has nvim-dap and nvim-dap-ui preconfigured. I have installed and configured nvim-dap-go to add golang debugger configuration. If I place a breakpoint on a line marked with "*" and start debugging, the debugger skips over the fmt.Fscanf() and goes somewhere deep into golang's source code. It does not wait for user input and I assume the reason is it doesn't have any terminal to take user input from. How can I configure my settings so that the debugger would wait for user input?

image

I'm learning go and I write simple standard i/o programs. Here's some code: ```go package main import ( "fmt" "math" "bufio" "os" "strconv" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) * var repeatAmount int fmt.Fscanf(reader, "%d\n", &repeatAmount) for i := 0; i < repeatAmount; i++ { var numberOfProgs int fmt.Fscanf(reader, "%d\n", &numberOfProgs) . . . ``` I use lunarvim, which has nvim-dap and nvim-dap-ui preconfigured. I have installed and configured nvim-dap-go to add golang debugger configuration. If I place a breakpoint on a line marked with "\*" and start debugging, the debugger skips over the `fmt.Fscanf()` and goes somewhere deep into golang's source code. It does not wait for user input and I assume the reason is it doesn't have any terminal to take user input from. How can I configure my settings so that the debugger would wait for user input? ![image](https://user-images.githubusercontent.com/39898616/213135985-958b1216-a48d-4486-b0cb-89c3cee12dda.png)
leoluz commented 2023-02-08 06:22:14 +03:00 (Migrated from github.com)

You can run the program in the terminal and attach (option 4) to the running process selecting the correct pid.

You can run the program in the terminal and attach (option 4) to the running process selecting the correct pid.
stale[bot] commented 2023-08-07 08:15:50 +03:00 (Migrated from github.com)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
NeonXP/nvim-dap-go#31
No description provided.