Re: [go-nuts] hook into os.Stdout / os.Stderr

2020-09-20 Thread 'Axel Wagner' via golang-nuts
As os.Stdout/os.Stderr are *os.File, not io.Writer, you need to go a step further and use os.Pipe . Something like this: https://play.golang.org/p/V6ygCmwlsiz TBH, it's not great to do this. As you can tell from the code, this is pretty complicated and if you want

Re: [go-nuts] hook into os.Stdout / os.Stderr

2020-09-19 Thread Raffaele Sena
You can create your own writer and overwrite os.Stdout/Stderr (just supply your own write method with the appropriate before/after hooks) Sent from my iPhone > On Sep 19, 2020, at 12:38 PM, Alexander Mills > wrote: > > Forgive me for this pigeon code, I am looking to do something like: > >

[go-nuts] hook into os.Stdout / os.Stderr

2020-09-19 Thread Alexander Mills
Forgive me for this pigeon code, I am looking to do something like: os.Stdout.BeforeWrite(func (){ }); os.Stderr.AfterWrite(func(){ }) so I can hook into the system and clear the terminal before hand, and write a status line, after wards. Is this possible? -- You received this message