I am using Delve to debug and having issues with the best way to handle stdin/stdout.
The first problem is that I cannot read the console. I have a function that takes use onput from the console:
func readConsole() string {
reader := bufio.NewReader(os.Stdin)
entry, err := reader.ReadString('\n')
if err != nil {
tlog.Fatal(fmt.Errorf("readConsole(): Error reading console input. %v", err))
}
entry = strings.Replace(entry, "\n", "", -1)
return entry
}
The following "bad file descriptor" error is returned by ReadString():
F0208 21:03:56.574021 429026 configurator.go:81] readConsole(): Error reading console input. read /dev/stdin: bad file descriptor
The second problem is that fmt.Printf() works when I just run the app, but if I am stepping through source code fmt.Printf() does not display anything.
I get that dlv is competing for input and output via the console, but not sure how to manage the competing requirements.