From 26c26290c3ec4bc75ba9f93d69ab53a878dfc904 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 19 Oct 2018 15:05:40 -0400 Subject: [PATCH] go/*: fix pre-1.11 tests packagestest.Modules is now available pre-go1.11 but doesn't add itself to packagestest.All. strings.ReplaceAll is not available in pre-go1.11 Change-Id: Ia8bf0e82bb853c6f29d31ca5c54651097342b19c Reviewed-on: https://go-review.googlesource.com/c/143419 Reviewed-by: Ian Cottrell --- go/analysis/multichecker/multichecker.go | 4 ++-- go/packages/packagestest/modules.go | 6 ------ go/packages/packagestest/modules_111.go | 7 +++++++ 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 go/packages/packagestest/modules_111.go diff --git a/go/analysis/multichecker/multichecker.go b/go/analysis/multichecker/multichecker.go index 36e5f825..27406fa0 100644 --- a/go/analysis/multichecker/multichecker.go +++ b/go/analysis/multichecker/multichecker.go @@ -53,7 +53,7 @@ func Main(analyzers ...*analysis.Analyzer) { args := flag.Args() if len(args) == 0 { - fmt.Fprintln(os.Stderr, strings.ReplaceAll(usage, "PROGNAME", progname)) + fmt.Fprintln(os.Stderr, strings.Replace(usage, "PROGNAME", progname, -1)) fmt.Fprintf(os.Stderr, "Run '%[1]s help' for more detail,\n"+ " or '%[1]s help name' for details and flags of a specific analyzer.\n", progname) @@ -73,7 +73,7 @@ func Main(analyzers ...*analysis.Analyzer) { func help(progname string, analyzers []*analysis.Analyzer, args []string) { // No args: show summary of all analyzers. if len(args) == 0 { - fmt.Println(strings.ReplaceAll(usage, "PROGNAME", progname)) + fmt.Println(strings.Replace(usage, "PROGNAME", progname, -1)) fmt.Println("Registered analyzers:") fmt.Println() sort.Slice(analyzers, func(i, j int) bool { diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go index 039b2d40..01004c05 100644 --- a/go/packages/packagestest/modules.go +++ b/go/packages/packagestest/modules.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.11 - package packagestest import ( @@ -34,10 +32,6 @@ import ( // /sometemporarydirectory/repoa var Modules = modules{} -func init() { - All = append(All, Modules) -} - type modules struct{} func (modules) Name() string { diff --git a/go/packages/packagestest/modules_111.go b/go/packages/packagestest/modules_111.go new file mode 100644 index 00000000..a116ae21 --- /dev/null +++ b/go/packages/packagestest/modules_111.go @@ -0,0 +1,7 @@ +// +build go1.11 + +package packagestest + +func init() { + All = append(All, Modules) +}