From dcbf83b1d968248deeb51a356d10110c2f980274 Mon Sep 17 00:00:00 2001 From: Pal Sivertsen Date: Tue, 31 Oct 2017 09:36:58 +0100 Subject: [PATCH] Fixes #17 --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index cb2f2d5..791a205 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ func main() { "don't read files that contain the given comma-separated strings (use to avoid /testdata, etc) ") // hack for testing code with build flags flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", "a list of build tags") + var ci = flag.Bool("ci", false, "Enables non zero exit code if any dead code is found during analysis") flag.Parse() // handle ignore list ucf.Ignore = strings.Split(ignoreList, ",") @@ -54,4 +55,7 @@ func main() { for _, o := range unusedObjects { fmt.Printf("%s\n", o) } + if *ci { + os.Exit(len(unusedObjects)) + } }