1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// +build !windows,!plan9,!solaris package goterm import ( "os" "golang.org/x/sys/unix" ) func getWinsize() (*unix.Winsize, error) { ws, err := unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ) if err != nil { return nil, os.NewSyscallError("GetWinsize", err) } return ws, nil }