mirror of
https://github.com/minio/minio.git
synced 2025-11-13 23:31:37 -05:00
A better way to print prettified json syntax error msg
This commit is contained in:
committed by
Harshavardhana
parent
db293aedb7
commit
b5ea05d839
46
vendor/github.com/olekukonko/ts/ts_x.go
generated
vendored
Normal file
46
vendor/github.com/olekukonko/ts/ts_x.go
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// +build !windows
|
||||
|
||||
// Copyright 2014 Oleku Konko All rights reserved.
|
||||
// Use of this source code is governed by a MIT
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This module is a Terminal API for the Go Programming Language.
|
||||
// The protocols were written in pure Go and works on windows and unix systems
|
||||
|
||||
package ts
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Get Windows Size
|
||||
func GetSize() (ws Size, err error) {
|
||||
_, _, ec := syscall.Syscall(syscall.SYS_IOCTL,
|
||||
uintptr(syscall.Stdout),
|
||||
uintptr(TIOCGWINSZ),
|
||||
uintptr(unsafe.Pointer(&ws)))
|
||||
|
||||
err = getError(ec)
|
||||
|
||||
if TIOCGWINSZ == 0 && err != nil {
|
||||
ws = Size{80, 25, 0, 0}
|
||||
}
|
||||
return ws, err
|
||||
}
|
||||
|
||||
func getError(ec interface{}) (err error) {
|
||||
switch v := ec.(type) {
|
||||
|
||||
case syscall.Errno: // Some implementation return syscall.Errno number
|
||||
if v != 0 {
|
||||
err = syscall.Errno(v)
|
||||
}
|
||||
|
||||
case error: // Some implementation return error
|
||||
err = ec.(error)
|
||||
default:
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user