Skip to content

Update sample.go #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions json/sample/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"os"
"runtime"
"strconv"
"strings"
"syscall"
Expand All @@ -10,13 +11,26 @@ import (
)

const (
ONE_MSEC = 1000 * 1000
_TIOCGWINSZ = 0x5413 // On OSX use 1074295912. Thanks zeebo
NUM = 50
GOOS string = runtime.GOOS
ONE_MSEC = 1000 * 1000
NUM = 50
)

var (
_TIOCGWINSZ int
)

func main() {

switch GOOS {
case "darwin":
_TIOCGWINSZ = 1074295912 // On OSX use 1074295912. Thanks zeebo
case "linux":
case "windows":
fallthrough
default:
_TIOCGWINSZ = 0x5413
}
var bar string

cols := TerminalWidth()
Expand Down Expand Up @@ -59,7 +73,7 @@ type winsize struct {
Ypixel uint16
}

func GetWinsize() (*winsize, os.Error) {
func GetWinsize() (*winsize, error) {
ws := new(winsize)

r1, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
Expand All @@ -69,7 +83,7 @@ func GetWinsize() (*winsize, os.Error) {
)

if int(r1) == -1 {
return nil, os.NewSyscallError("GetWinsize", int(errno))
return nil, errno
}
return ws, nil
}