From 744fc4caad20588e394ddd7a1af4d7a9ecabe3ac Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sat, 18 May 2019 11:44:18 +0200 Subject: [PATCH] fix build break for plan9 --- go.sum | 1 + terminal_check_nacl.go | 11 ----------- ...heck_js.go => terminal_check_no_terminal.go | 2 +- terminal_check_notappengine.go | 2 +- terminal_check_windows.go | 18 ++++++++++++++++-- terminal_notwindows.go | 8 -------- terminal_windows.go | 18 ------------------ text_formatter.go | 4 ---- travis/cross_build.sh | 2 +- 9 files changed, 20 insertions(+), 46 deletions(-) delete mode 100644 terminal_check_nacl.go rename terminal_check_js.go => terminal_check_no_terminal.go (79%) delete mode 100644 terminal_notwindows.go delete mode 100644 terminal_windows.go diff --git a/go.sum b/go.sum index 7976428..596c318 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs= github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/terminal_check_nacl.go b/terminal_check_nacl.go deleted file mode 100644 index 59d1e2c..0000000 --- a/terminal_check_nacl.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build nacl - -package logrus - -import ( - "io" -) - -func checkIfTerminal(w io.Writer) bool { - return false -} diff --git a/terminal_check_js.go b/terminal_check_no_terminal.go similarity index 79% rename from terminal_check_js.go rename to terminal_check_no_terminal.go index 0c20975..97af92c 100644 --- a/terminal_check_js.go +++ b/terminal_check_no_terminal.go @@ -1,4 +1,4 @@ -// +build js +// +build js nacl plan9 package logrus diff --git a/terminal_check_notappengine.go b/terminal_check_notappengine.go index a0b571a..3293fb3 100644 --- a/terminal_check_notappengine.go +++ b/terminal_check_notappengine.go @@ -1,4 +1,4 @@ -// +build !appengine,!js,!windows,!nacl +// +build !appengine,!js,!windows,!nacl,!plan9 package logrus diff --git a/terminal_check_windows.go b/terminal_check_windows.go index 3b9d286..572889d 100644 --- a/terminal_check_windows.go +++ b/terminal_check_windows.go @@ -6,15 +6,29 @@ import ( "io" "os" "syscall" + + sequences "github.com/konsorten/go-windows-terminal-sequences" ) +func initTerminal(w io.Writer) { + switch v := w.(type) { + case *os.File: + sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true) + } +} + func checkIfTerminal(w io.Writer) bool { + var ret bool switch v := w.(type) { case *os.File: var mode uint32 err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode) - return err == nil + ret = (err == nil) default: - return false + ret = false } + if ret { + initTerminal(w) + } + return ret } diff --git a/terminal_notwindows.go b/terminal_notwindows.go deleted file mode 100644 index 3dbd237..0000000 --- a/terminal_notwindows.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !windows - -package logrus - -import "io" - -func initTerminal(w io.Writer) { -} diff --git a/terminal_windows.go b/terminal_windows.go deleted file mode 100644 index b4ef528..0000000 --- a/terminal_windows.go +++ /dev/null @@ -1,18 +0,0 @@ -// +build !appengine,!js,windows - -package logrus - -import ( - "io" - "os" - "syscall" - - sequences "github.com/konsorten/go-windows-terminal-sequences" -) - -func initTerminal(w io.Writer) { - switch v := w.(type) { - case *os.File: - sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true) - } -} diff --git a/text_formatter.go b/text_formatter.go index 1569161..e01587c 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -84,10 +84,6 @@ type TextFormatter struct { func (f *TextFormatter) init(entry *Entry) { if entry.Logger != nil { f.isTerminal = checkIfTerminal(entry.Logger.Out) - - if f.isTerminal { - initTerminal(entry.Logger.Out) - } } } diff --git a/travis/cross_build.sh b/travis/cross_build.sh index 7bb9449..545d8c3 100755 --- a/travis/cross_build.sh +++ b/travis/cross_build.sh @@ -1,5 +1,5 @@ #!/bin/bash if [[ "$TRAVIS_GO_VERSION" =~ ^1.\12\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - /tmp/gox/gox -build-lib -all -os '!plan9 !nacl' + /tmp/gox/gox -build-lib -all fi