terminal.IsTerminal() is not available on FreeBSD until go1.3

This commit is contained in:
Andrey Smirnov
2014-02-10 22:48:12 +04:00
parent 1bba0319cb
commit 766d634fbb
3 changed files with 20 additions and 3 deletions

View File

@@ -1,10 +1,8 @@
package utils
import (
"code.google.com/p/go.crypto/ssh/terminal"
"fmt"
"github.com/cheggaaa/pb"
"syscall"
)
const (
@@ -54,7 +52,7 @@ func (p *Progress) InitBar(count int64, isBytes bool) {
if p.bar != nil {
panic("bar already initialized")
}
if terminal.IsTerminal(syscall.Stdout) {
if RunningOnTerminal() {
p.bar = pb.New(0)
p.bar.Total = count
p.bar.NotPrint = true

12
utils/terminal.go Normal file
View File

@@ -0,0 +1,12 @@
// +build !freebsd
package utils
import (
"code.google.com/p/go.crypto/ssh/terminal"
"syscall"
)
func RunningOnTerminal() bool {
return terminal.IsTerminal(syscall.Stdout)
}

7
utils/terminal_bsd.go Normal file
View File

@@ -0,0 +1,7 @@
// +build freebsd
package utils
func RunningOnTerminal() bool {
return false
}