How do I get the terminal size in Go. In C it would look like this:
struct ttysize ts;
ioctl(0, TIOCGWINSZ, &ts);
But how to i access TIOCGWINSZ in Go
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The cgo compiler can’t handle variable arguments in a c function and macros in c header files at present, so you can’t do a simple
To get around the macros use a constant, so
However cgo will still barf on the … in ioctl’s prototype. Your best bet would be to wrap ioctl with a c function taking a specific number of arguments and link that in. As a hack you can do that in the comment above import “C”
I’ve not tested this, but something similar should work.