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 <iancottrell@google.com>
diff --git a/go/analysis/multichecker/multichecker.go b/go/analysis/multichecker/multichecker.go
index 36e5f82..27406fa 100644
--- a/go/analysis/multichecker/multichecker.go
+++ b/go/analysis/multichecker/multichecker.go
@@ -53,7 +53,7 @@
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 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 039b2d4..01004c0 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 @@
// /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 0000000..a116ae2
--- /dev/null
+++ b/go/packages/packagestest/modules_111.go
@@ -0,0 +1,7 @@
+// +build go1.11
+
+package packagestest
+
+func init() {
+ All = append(All, Modules)
+}