From 7927de24b5a93f12283a258b9d0650ce9ca3e959 Mon Sep 17 00:00:00 2001 From: frederikhors <41120635+frederikhors@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:43:38 +0100 Subject: [PATCH] remove things that are no longer needed; add new build tags --- conf/lex.go | 2 +- conf/parse_test.go | 8 ++++---- daemon.go | 4 ++-- notify/notify.go | 4 ++-- proc.go | 15 --------------- shell/proc_windows.go | 4 ++-- shell/shell.go | 2 +- 7 files changed, 12 insertions(+), 27 deletions(-) diff --git a/conf/lex.go b/conf/lex.go index 22ce2a7..ffad043 100644 --- a/conf/lex.go +++ b/conf/lex.go @@ -399,7 +399,7 @@ func lexVariables(l *lexer) stateFn { } } -func lexTop(l *lexer) stateFn { +func lexTop(*lexer) stateFn { return lexVariables } diff --git a/conf/parse_test.go b/conf/parse_test.go index fc874cf..c5aed25 100644 --- a/conf/parse_test.go +++ b/conf/parse_test.go @@ -159,7 +159,7 @@ var parseTests = []struct { Blocks: []Block{ { Include: []string{"foo"}, - Preps: []Prep{Prep{Command: "command"}}, + Preps: []Prep{{Command: "command"}}, }, }, }, @@ -171,7 +171,7 @@ var parseTests = []struct { Blocks: []Block{ { Include: []string{"foo"}, - Preps: []Prep{Prep{Command: "command", Onchange: true}}, + Preps: []Prep{{Command: "command", Onchange: true}}, }, }, }, @@ -183,7 +183,7 @@ var parseTests = []struct { Blocks: []Block{ { Include: []string{"foo"}, - Preps: []Prep{Prep{Command: "command\n-one\n-two"}}, + Preps: []Prep{{Command: "command\n-one\n-two"}}, }, }, }, @@ -195,7 +195,7 @@ var parseTests = []struct { Blocks: []Block{ { Include: []string{"foo", "bar"}, - Preps: []Prep{Prep{Command: "command"}}, + Preps: []Prep{{Command: "command"}}, }, }, }, diff --git a/daemon.go b/daemon.go index 5f86c7f..27f39ea 100644 --- a/daemon.go +++ b/daemon.go @@ -94,7 +94,7 @@ func (d *daemon) Restart() { } } -func (d *daemon) Shutdown(sig os.Signal) error { +func (d *daemon) Shutdown() error { d.log.Notice(">> stopping") d.stop = true if d.ex != nil { @@ -160,7 +160,7 @@ func (dp *DaemonPen) Shutdown(sig os.Signal) { defer dp.Unlock() if dp.daemons != nil { for _, d := range dp.daemons { - d.Shutdown(sig) + d.Shutdown() } } } diff --git a/notify/notify.go b/notify/notify.go index 6faa1e3..84e3bae 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -33,7 +33,7 @@ type GrowlNotifier struct { } // Push implements Notifier -func (GrowlNotifier) Push(title string, text string, iconPath string) { +func (GrowlNotifier) Push(_ string, text string, _ string) { cmd := exec.Command( "growlnotify", "-n", prog, "-d", prog, "-m", text, prog, ) @@ -45,7 +45,7 @@ type LibnotifyNotifier struct { } // Push implements Notifier -func (LibnotifyNotifier) Push(title string, text string, iconPath string) { +func (LibnotifyNotifier) Push(_ string, text string, _ string) { cmd := exec.Command( "notify-send", prog, text, ) diff --git a/proc.go b/proc.go index faffb63..3430c50 100644 --- a/proc.go +++ b/proc.go @@ -1,10 +1,7 @@ package modd import ( - "bufio" - "io" "strings" - "sync" "github.com/cortesi/termlog" ) @@ -33,15 +30,3 @@ func niceHeader(preamble string, command string) string { command = termlog.DefaultPalette.Header.SprintFunc()(shortCommand(command)) return pre + command } - -func logOutput(wg *sync.WaitGroup, fp io.ReadCloser, out func(string, ...interface{})) { - defer wg.Done() - r := bufio.NewReader(fp) - for { - line, _, err := r.ReadLine() - if err != nil { - return - } - out("%s", string(line)) - } -} diff --git a/shell/proc_windows.go b/shell/proc_windows.go index 2cb899d..1b6273f 100644 --- a/shell/proc_windows.go +++ b/shell/proc_windows.go @@ -1,9 +1,9 @@ +//go:build windows // +build windows package shell import ( - "os" "os/exec" "strconv" "syscall" @@ -16,6 +16,6 @@ func prepCmd(cmd *exec.Cmd) { } } -func (e *Executor) sendSignal(sig os.Signal) error { +func (e *Executor) sendSignal() error { return exec.Command("taskkill", "/f", "/t", "/pid", strconv.Itoa(e.cmd.Process.Pid)).Run() } diff --git a/shell/shell.go b/shell/shell.go index c0b6aec..08f7a52 100644 --- a/shell/shell.go +++ b/shell/shell.go @@ -153,7 +153,7 @@ func (e *Executor) Signal(sig os.Signal) error { if !e.running() { return fmt.Errorf("executor not running") } - return e.sendSignal(sig) + return e.sendSignal() } func (e *Executor) Stop() error {