<p dir="auto">by <strong>michael.jones</strong>:</p>
<pre class="notranslate">Developer noted presence of JSON marshalling/unmarshalling support in Int but not in Rat.</pre>
<p dir="auto">I would like to propose the addition of a set of functions and supporting data types to support getting / setting terminal window size across platforms.</p>
<p dir="auto">This would also likely require the addition of something like this to x/sys:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="func GetWindowSize(fd int) (winsize *Winsize, err error) {}
func SetWindowSize(fd int, ws *Winsize) (err error) {}
type Winsize struct {
    Row    uint16
    Col    uint16
    Xpixel uint16
    Ypixel uint16
}"><pre class="notranslate"><code class="notranslate">func GetWindowSize(fd int) (winsize *Winsize, err error) {}
func SetWindowSize(fd int, ws *Winsize) (err error) {}
type Winsize struct {
    Row    uint16
    Col    uint16
    Xpixel uint16
    Ypixel uint16
}
</code></pre></div>
<p dir="auto">On Linux, OS X, etc. this is done via syscalls using ioctl(), etc.  On Windows, this is done possibly via GetConsoleScreenBufferInfo and SetConsoleWindowInfo.  On Solaris, this is done via libc.ioctl().</p>
<p dir="auto">Docker (pkg/term/*) and other Go-based projects like to retrieve or set this information, it would be helpful if this was abstracted away for various projects as can be seen in a simple github search of Go source files:</p>
<p dir="auto"><a href="https://github.com/search?utf8=%E2%9C%93&amp;q=%22TIOCGWINSZ%22+extension%3Ago&amp;type=Code&amp;ref=advsearch&amp;l=">https://github.com/search?utf8=%E2%9C%93&amp;q=%22TIOCGWINSZ%22+extension%3Ago&amp;type=Code&amp;ref=advsearch&amp;l=</a></p>
<p dir="auto">I am willing to provide the implementation and tests for Solaris, and Linux, and I can attempt one for Windows.</p>
<p dir="auto">I have not proposed an addition before to any of the Go packages or tools, so please forgive me if I have not adhered to the correct process ( I'm attempting to follow <a href="https://github.com/golang/proposal#readme">https://github.com/golang/proposal#readme</a> ).</p>
<p dir="auto">I don't know if the sys package is the most appropriate place for this or not; I'm just trying to figure out how to avoid the current situation of duplicating terminal information code across various Go projects in the community leading to them not working as expected or being unsupported on some platforms.</p>