0

I am trying to implement this behaviour in my golang CLI based program. The behaviour is simple, I just want to print something to console while user is typing something.

This is the code I have written.

// %a code that reads the user input in a different thread% 
fmt.Print("\r[*] this is a message.") // erases the current line then prints the message
fmt.Print("\n\r") // creates new empty line
fmt.Print(">>> " + %CURRENT_STDIN_LINE_BUFFER%) // prints the prompt ">>>" then writes the user input 

The only missing thing is equilavent of readline.get_line_buffer() python function in golang.

Oğuzhan Topçu
  • 571
  • 2
  • 8
  • 17
  • [A possibly limited implementation of GNU Readline exists](https://github.com/chzyer/readline) if you just want to use that, or you can [try an alternative](https://github.com/peterh/liner) that provides some similar functionality. –  Aug 13 '17 at 15:13
  • maybe this can help: https://stackoverflow.com/a/20895629/1135424 – nbari Aug 13 '17 at 17:55
  • Does this answer your question? [How to read from standard input in the console?](https://stackoverflow.com/questions/20895552/how-to-read-from-standard-input-in-the-console) – Gustavo Chaín Jan 04 '21 at 14:32

0 Answers0