Skip to content

Unable to read stdin input in debug mode #1274

@zonghaishang

Description

@zonghaishang

I am a go language enthusiast and I am just getting started.
Here is my question:
In debug mode, the program is blocked in stdin and cannot be entered.

  1. What version of Delve are you using (dlv version)?
Delve Debugger
Version: 1.0.0
Build: 86120a3b4038318b08c2898059733a7bf1499ee5
  1. What version of Go are you using? (go version)?
go version go1.9.3 darwin/amd64
  1. What operating system and processor architecture are you using?
Darwin yiji.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
  1. What did you do?
    In debug mode, the program is blocked in stdin and cannot be entered.

  2. What did you expect to see?
    The program receives input and the debug runs normally.

  3. What did you see instead?
    Here is my simple code :

package main

import (
	"bufio"
	"os"
	"fmt"
)

func main()  {
	input := bufio.NewScanner(os.Stdin)
	words := make(map[string]int)
	for input.Scan() {
		fmt.Println("Received:" + input.Text())
		if len(input.Text()) <= 0 {
			break
		}
		words[input.Text()]++
	}

	for word, n := range words {
		if n > 1 {
			fmt.Printf("%d %s\n", n, word)
		}
	}
}

Is this a bug?

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions