Closed haifenghuang closed 4 years ago
The problem is that you called os.Stdin.Read instead of l.Prompt. Why would you do that?
(If you really really need to bake/unbake the terminal mode and temporarily suspend liner, you can use liner.TerminalMode. But I suggest using liner for everything or nothing.)
Because I designed a language REPL, the language support below statement:
let a;
stdin >> a; # read standard input into variable 'a'
If above code is in a file, then it's OK, but if in the REPL, it has problem as stated above.
I just made a new program as below:
On the
n, _ := os.Stdion.Read(buffer)
line, When I enter a character 'b' , the output isn=1, str=b
, please see below output:It only accept one character and print the result. What was the problem?