On Sat, 4 May 2019, 04:33 Robert Engels, <reng...@ix.netcom.com> wrote:

> Since people keep referring to “flush”. I’ll chime in again. Thus is not
> the correct way to do this, as many routines buffer input. Flushing the
> driver does nothing to characters already in the buffer. Flushing the
> driver is only appropriate if also doing direct reads from the driver - if
> you are using any stdlib based streams this will probably be a problem.
>

Unlike several other languages, Go does not automatically apply buffering
to stdio streams unless you explicitly add it (for example using the bufio
package).

>
> On May 3, 2019, at 8:40 PM, Matt Harden <matt.har...@gmail.com> wrote:
>
> You may want http://godoc/github.com/pkg/term/termios. It looks like it
> supports Tcflush on UNIX, including Solaris:
> https://github.com/pkg/term/blob/master/termios/termios_solaris.go#L63.
>
> On Fri, May 3, 2019 at 9:45 AM gbarr <gmb...@gmail.com> wrote:
>
>> For BSD systems I think you need to use TIOCFLUSH instead of TCFLSH
>>
>> On Friday, May 3, 2019 at 1:28:36 PM UTC+1, Steve Mynott wrote:
>>>
>>> I've a terminal app where I read y/n confirm using  fmt.Scanln and I'm
>>> trying to flush the keyboard buffer before this.
>>>
>>> On linux (and probably other UNIX systems) I can use
>>>
>>> unix.Syscall(unix.SYS_IOCTL, 0, unix.TCFLSH, 0)
>>>
>>> but this isn't portable (specifically to macOS which it would be nice to
>>> support) since on cross compiling I see "undefined: unix.TCFLSH" Maybe this
>>> is some BSDism?
>>>
>>> Rossetta code suggests using a ncurses function from
>>> https://github.com/rthornton128/goncurses but that seems sort of ugly?
>>>
>>> https://rosettacode.org/wiki/Keyboard_input/Flush_the_keyboard_buffer#Go
>>>
>>>
>>> Is there a simple way which works at least on UNIX and macOS?
>>>
>>> --
>>> Steve Mynott <steve...@gmail.com>
>>> cv25519/ECF8B611205B447E091246AF959E3D6197190DD5
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to