// +build !windows

package gottyclient

import (
	"encoding/json"
	"fmt"
	"golang.org/x/sys/unix"
	"os"
	"os/signal"
	"syscall"
)

func notifySignalSIGWINCH(c chan<- os.Signal) {
	signal.Notify(c, syscall.SIGWINCH)
}

func resetSignalSIGWINCH() {
	signal.Reset(syscall.SIGWINCH)
}

func syscallTIOCGWINSZ() ([]byte, error) {
	ws, err := unix.IoctlGetWinsize(0, 0)
	if err != nil {
		return nil, fmt.Errorf("ioctl error: %v", err)
	}
	tws := winsize{Rows: ws.Row, Columns: ws.Col}
	b, err := json.Marshal(tws)
	if err != nil {
		return nil, fmt.Errorf("json.Marshal error: %v", err)
	}
	return b, err
}

// +build !windows

package gottyclient

import (
	"encoding/json"
	"fmt"
	"golang.org/x/sys/unix"
	"os"
	"os/signal"
	"syscall"
)

func notifySignalSIGWINCH(c chan<- os.Signal) {
	signal.Notify(c, syscall.SIGWINCH)
}

func resetSignalSIGWINCH() {
	signal.Reset(syscall.SIGWINCH)
}

func syscallTIOCGWINSZ() ([]byte, error) {
	ws, err := unix.IoctlGetWinsize(0, 0)
	if err != nil {
		return nil, fmt.Errorf("ioctl error: %v", err)
	}
	b, err := json.Marshal(ws)
	if err != nil {
		return nil, fmt.Errorf("json.Marshal error: %v", err)
	}
	return b, err
}

--- 
+++ 
@@ -24,7 +24,8 @@
 	if err != nil {
 		return nil, fmt.Errorf("ioctl error: %v", err)
 	}
-	b, err := json.Marshal(ws)
+	tws := winsize{Rows: ws.Row, Columns: ws.Col}
+	b, err := json.Marshal(tws)
 	if err != nil {
 		return nil, fmt.Errorf("json.Marshal error: %v", err)
 	}
Fix bug when resizing terminal
