From 71ef345596eb4bb94c8821a49cf7b2bc74aced1a Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Tue, 4 Jul 2023 11:36:16 +0200 Subject: [PATCH] Disable debugging specific code to remove go-ps dependency --- exit.go | 18 ++++++++---------- go.mod | 1 - go.sum | 2 -- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/exit.go b/exit.go index 80ed064..77a206c 100644 --- a/exit.go +++ b/exit.go @@ -6,8 +6,6 @@ import ( "runtime/debug" "strconv" "strings" - - "github.com/mitchellh/go-ps" ) // AllowExit lets you disable the call to os.Exit() in ExitXxx() functions of this package. @@ -66,14 +64,14 @@ func ExitError(err error) { // The function will recover from the condition and exit with a proper UNKNOWN status, while showing error // and the call stack. func CatchPanic() { - ppid := os.Getppid() - if parent, err := ps.FindProcess(ppid); err == nil { - if parent.Executable() == "dlv" { - // seems to be a debugger, don't continue with recover - return - } - } - + // This can be enabled when working with a debugger + // ppid := os.Getppid() + // if parent, err := ps.FindProcess(ppid); err == nil { + // if parent.Executable() == "dlv" { + // // seems to be a debugger, don't continue with recover + // return + // } + // } if r := recover(); r != nil { output := fmt.Sprint("Golang encountered a panic: ", r) if PrintStack { diff --git a/go.mod b/go.mod index 6e6f228..1da9b2c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/NETWAYS/go-check go 1.14 require ( - github.com/mitchellh/go-ps v1.0.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 3389d0c..212724f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= -github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=