-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Prevent readline to print. #26
Comments
@rivalo However, sorry for the missing comments. ಥ_ಥ |
rl, err := readline.New("> ")
if err != nil {
panic(err)
}
defer rl.Close()
log.SetOutput(rl.Stderr()) // let "log" write to l.Stderr instead of os.Stderr
for {
line, err := rl.Readline()
if err != nil { // io.EOF
break
}
if line == ":quit" {
break
}
dg.ChannelMessageSend(State.Channel.ID, line)
} This is the only code from readline I'm currently using. Just like in the demo's, you do a 'say hello' command then the program responds by logging 'hello' over and over, but the initial 'say hello' command including it's newline prompt I was wondering if there is an option to prevent that from happening using the current library functions. Else I have to try to hack something together that works 😃 |
I'm currently working on a CLI client for a chat application and I really like how this library manipulates the log output. There is currently besides this library no Go library available that refreshes the stdout without including all kinds of lay-outing I do not need.
But I have a question: Is it possible to prevent Readline() from printing to the terminal output?
Currently my output looks like this
Where
(INSERT) >
is the prompt for reading the line, and the next line simply returns the sent message inside the chat channel.I want to prevent the User's message from displaying twice but keep the consistency with the messages from others, which means that after a
\n
readline() shouldn't print its just received line to the stdout.Is there currently an option or workaround for this I'm overlooking in the documentation?
(Please, in future, add comments above exported functions, it makes the godoc documentation easier to read)
The text was updated successfully, but these errors were encountered: