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>
This commit is contained in:
Alan Donovan 2018-10-19 15:05:40 -04:00
parent 9545aa7b51
commit 26c26290c3
3 changed files with 9 additions and 8 deletions

View File

@ -53,7 +53,7 @@ func Main(analyzers ...*analysis.Analyzer) {
args := flag.Args() args := flag.Args()
if len(args) == 0 { 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"+ 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", " or '%[1]s help name' for details and flags of a specific analyzer.\n",
progname) progname)
@ -73,7 +73,7 @@ func Main(analyzers ...*analysis.Analyzer) {
func help(progname string, analyzers []*analysis.Analyzer, args []string) { func help(progname string, analyzers []*analysis.Analyzer, args []string) {
// No args: show summary of all analyzers. // No args: show summary of all analyzers.
if len(args) == 0 { 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("Registered analyzers:")
fmt.Println() fmt.Println()
sort.Slice(analyzers, func(i, j int) bool { sort.Slice(analyzers, func(i, j int) bool {

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build go1.11
package packagestest package packagestest
import ( import (
@ -34,10 +32,6 @@ import (
// /sometemporarydirectory/repoa // /sometemporarydirectory/repoa
var Modules = modules{} var Modules = modules{}
func init() {
All = append(All, Modules)
}
type modules struct{} type modules struct{}
func (modules) Name() string { func (modules) Name() string {

View File

@ -0,0 +1,7 @@
// +build go1.11
package packagestest
func init() {
All = append(All, Modules)
}