From b66013fa8dbdf5540a474aecfed5a925bf99a98f Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 8 Feb 2024 16:59:45 +0100 Subject: [PATCH] analyzer: make string concatenation optional --- analyzer/analyzer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/analyzer/analyzer.go b/analyzer/analyzer.go index ad312ca..0d32826 100644 --- a/analyzer/analyzer.go +++ b/analyzer/analyzer.go @@ -22,6 +22,7 @@ type perfSprint struct { errorf bool sprintf1 bool fiximports bool + strconcat bool } func newPerfSprint() *perfSprint { @@ -31,6 +32,7 @@ func newPerfSprint() *perfSprint { errorf: true, sprintf1: true, fiximports: true, + strconcat: true, } } @@ -47,6 +49,7 @@ func New() *analysis.Analyzer { r.Flags.BoolVar(&n.errorf, "errorf", true, "optimizes fmt.Errorf") r.Flags.BoolVar(&n.sprintf1, "sprintf1", true, "optimizes fmt.Sprintf with only one argument") r.Flags.BoolVar(&n.fiximports, "fiximports", true, "fix needed imports from other fixes") + r.Flags.BoolVar(&n.strconcat, "strconcat", true, "optimizes into strings concatenation") return r } @@ -143,7 +146,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) { switch verb { default: - if fn == "fmt.Sprintf" && isConcatable(verb) { + if fn == "fmt.Sprintf" && isConcatable(verb) && n.strconcat { break } return