From 60671c1308c325ab7dfcc59639d34b9c1fcc9b1b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 14 Jun 2019 04:20:29 -0700 Subject: [PATCH] add linux / windows build files Signed-off-by: Jeff Carr --- linux.go | 31 +++++++++++++++++++++++++++++++ shell.go | 8 -------- windows.go | 18 ++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 linux.go create mode 100644 windows.go diff --git a/linux.go b/linux.go new file mode 100644 index 0000000..e54e2fa --- /dev/null +++ b/linux.go @@ -0,0 +1,31 @@ +// +build linux,go1.7 + +// put stuff in here that you only want compiled under linux + +package shell + +import "log" +import "os" +import "os/signal" +import "syscall" + +// import "runtime" +// import "time" +// import "reflect" + +// import "git.wit.com/wit/shell" +// import "github.com/davecgh/go-spew/spew" + +import "github.com/wercker/journalhook" + +var sigChan chan os.Signal + +func handleSignal(err interface{}, ret int) { + log.Println("handleSignal() only should be compiled on linux") + sigChan = make(chan os.Signal, 3) + signal.Notify(sigChan, syscall.SIGUSR1) +} + +func UseJournalctl() { + journalhook.Enable() +} diff --git a/shell.go b/shell.go index cfa9b94..5f947a6 100644 --- a/shell.go +++ b/shell.go @@ -15,8 +15,6 @@ import "github.com/svent/go-nbreader" // import "log" import log "github.com/sirupsen/logrus" -// TODO this journalhook to be cross platform -// import "github.com/wercker/journalhook" // TODO: look at https://github.com/go-cmd/cmd/issues/20 // use go-cmd instead here? @@ -66,12 +64,6 @@ func Script(cmds string) int { return 0 } -/* -func UseJournalctl() { - journalhook.Enable() -} -*/ - func SpewOn() { spewOn = true } diff --git a/windows.go b/windows.go new file mode 100644 index 0000000..0bd3aa2 --- /dev/null +++ b/windows.go @@ -0,0 +1,18 @@ +// +build windows + +// put stuff in here that you only want compiled under windows + +package shell + +import "log" + +// import "git.wit.com/wit/shell" +// import "github.com/davecgh/go-spew/spew" + +func handleSignal(err interface{}, ret int) { + log.Println("handleSignal() windows doesn't do signals") +} + +func UseJournalctl() { + log.Println("journalctl doesn't exist on windows") +}