-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
by adriansinclair2007:
I have this code (I don't think that the messing with tty buffering is related):
exec.Command("/bin/stty", "-f", "/dev/tty",
"sane").Run()
fmt.Println("What file should I archive the level to?")
path, _, error := stdin.ReadLine()
fmt.Println("Rename the new level:")
name, _, error := stdin.ReadLine()
exec.Command("/bin/stty", "-f", "/dev/tty",
"-icanon", "min", "1").Run()
where stdin is defined as follows:
bufio.NewReader(os.stdin)
It was having strange problems so I logged the `path' variable and it showed me nothing
like what I input the first time, but showed me a somewhat corrupted version of my input
to the second prompt.
I fixed this by converting the []byte to a string (resulting in a copy) before I
prompted for the next input, so it seems clear that the memory allocated for `path' was
being prematurely reused. Maybe a bug in the bufio package, or maybe a bug in the
garbage collector (seems less likely).
I have go1, and I think it compiled with 6g (`go env' reports GOCHAR="6")Reactions are currently unavailable