Created
November 29, 2023 07:51
-
-
Save abiriadev/080c3353ada9004999c9a9ccdd6218e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt" | |
"golang.org/x/sys/unix" | |
) | |
func tCol() (int, error) { | |
var ws unix.Winsize | |
_, _, err := unix.Syscall( | |
unix.SYS_IOCTL, | |
uintptr(0), | |
uintptr(unix.TIOCGWINSZ), | |
uintptr(unsafe.Pointer(&ws)), | |
) | |
if err != 0 { | |
return 0, err | |
} | |
return int(ws.Col), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment