From 93140f0cc0aa15d469187689b1b8c2f6cfb55c98 Mon Sep 17 00:00:00 2001 From: Luc Stepniewski Date: Wed, 7 Sep 2016 15:43:29 +0200 Subject: [PATCH 1/2] No need to declare the variable, just check it is an integer No need to declare the variable, just check it is an integer --- pidfile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pidfile.go b/pidfile.go index dd667a8..b796d49 100644 --- a/pidfile.go +++ b/pidfile.go @@ -19,7 +19,7 @@ func getPidProcess(path string) (*os.Process, error) { return nil, err } - pid, err := strconv.Atoi(string(pidString)) + _, err := strconv.Atoi(string(pidString)) if err != nil { return nil, fmt.Errorf("%s fake", path) } From 7119fba5787394d78705b4a80b8b5b52c3c87f20 Mon Sep 17 00:00:00 2001 From: Luc Stepniewski Date: Wed, 7 Sep 2016 15:44:19 +0200 Subject: [PATCH 2/2] wrong pid changed. Corrected! --- pidfile.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pidfile.go b/pidfile.go index b796d49..337a6ef 100644 --- a/pidfile.go +++ b/pidfile.go @@ -19,7 +19,7 @@ func getPidProcess(path string) (*os.Process, error) { return nil, err } - _, err := strconv.Atoi(string(pidString)) + pid, err := strconv.Atoi(string(pidString)) if err != nil { return nil, fmt.Errorf("%s fake", path) } @@ -33,7 +33,7 @@ func getPidProcess(path string) (*os.Process, error) { func checkPidFileAlreadyExists(path string) error { if pidString, err := ioutil.ReadFile(path); err == nil { - if pid, err := strconv.Atoi(string(pidString)); err == nil { + if _, err := strconv.Atoi(string(pidString)); err == nil { if _, err := os.Stat(filepath.Join("/proc", string(pid))); err == nil { return fmt.Errorf("pid process is running") }