From 8792917753a87b8a5536834545bee35d57fb8581 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 8 Jun 2023 14:22:20 +0200 Subject: [PATCH] fix: move init to the main package Co-authored-by: Patrick Ohly --- cmd/nakedret/main.go | 7 +++++++ nakedret.go | 11 ++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/nakedret/main.go b/cmd/nakedret/main.go index 2238bf3..7eb8183 100644 --- a/cmd/nakedret/main.go +++ b/cmd/nakedret/main.go @@ -1,6 +1,8 @@ package main import ( + "go/build" + "golang.org/x/tools/go/analysis/singlechecker" "github.com/alexkohler/nakedret/v2" @@ -10,6 +12,11 @@ const ( DefaultLines = 5 ) +func init() { + // TODO allow build tags + build.Default.UseAllFiles = true +} + func main() { analyzer := nakedret.NakedReturnAnalyzer(DefaultLines) singlechecker.Main(analyzer) diff --git a/nakedret.go b/nakedret.go index 41979c3..f78bb8c 100644 --- a/nakedret.go +++ b/nakedret.go @@ -20,14 +20,7 @@ import ( "golang.org/x/tools/go/ast/inspector" ) -const ( - pwd = "./" -) - -func init() { - //TODO allow build tags - build.Default.UseAllFiles = true -} +const pwd = "./" func NakedReturnAnalyzer(defaultLines uint) *analysis.Analyzer { nakedRet := &NakedReturnRunner{} @@ -149,7 +142,7 @@ func parseInput(args []string, fset *token.FileSet) ([]*ast.File, error) { } } else { - //TODO clean this up a bit + // TODO clean this up a bit imPaths := importPaths([]string{arg}) for _, importPath := range imPaths { pkg, err := build.Import(importPath, ".", 0)