Live data from Hacker News

Using C Dynamic Libraries In Go Programs

goinggo.net

11–12 of 12 posts

Re: Using C Dynamic Libraries In Go Programs

#11

I wonder why the author didn't just read() in bytes from STDIN_FILENO? No need to use stuff like fget*.

Neither fget*() or read() from stdin would work because stdin is buffered.

It's possible to change the mode, but it would require calling the terminal control functions, and that'd requiring calling out to C anyway, so might as well use ncurses.

Re: Using C Dynamic Libraries In Go Programs

#12

I wonder why the author didn't just read() in bytes from STDIN_FILENO? No need to use stuff like fget*.

Neither fget*() or read() from stdin would work because stdin is buffered. It's possible to change the mode, but it would require calling the terminal control functions, and that'd requiring calling out to C anyway, so might as well use ncurses.

Nope, you don't have to touch C at all. The syscall package has all you need. But it's still a lot of lowlevel coding. Ncurses is probably easier.
Post reply on HN