You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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")
The text was updated successfully, but these errors were encountered:
««« backport 9e2011d9ed4b
bufio: discourage use of ReadLine
Too many people use it without reading what it does.
Those people want ReadBytes or ReadString.
Fixes#3906.
R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/6442087
»»»
by adriansinclair2007:
The text was updated successfully, but these errors were encountered: