x/tools: simplify and format code

Semi-mechanical changes using gofmt -s
and honnef.co/go/tools/cmd/gosimple.

Change-Id: I41bcf4bea5b16c4776b7cf6534b76aa59b3c022d
Reviewed-on: https://go-review.googlesource.com/37447
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
David R. Jenni 2017-02-27 20:11:17 +01:00 committed by Alan Donovan
parent 4968197297
commit 718875e4f9
9 changed files with 14 additions and 15 deletions

View File

@ -175,7 +175,7 @@ func doCallgraph(ctxt *build.Context, algo, format string, tests bool, args []st
} }
// Use the initial packages from the command line. // Use the initial packages from the command line.
args, err := conf.FromArgs(args, tests) _, err := conf.FromArgs(args, tests)
if err != nil { if err != nil {
return err return err
} }

View File

@ -4,17 +4,20 @@
package alias // @describe describe-pkg "alias" package alias // @describe describe-pkg "alias"
type I interface{ f() } // @implements implements-I "I" type I interface { // @implements implements-I "I"
f()
}
type N int type N int
func (N) f() {} func (N) f() {}
type M = N // @describe describe-def-M "M" type M = N // @describe describe-def-M "M"
var m M // @describe describe-ref-M "M" var m M // @describe describe-ref-M "M"
type O N // @describe describe-O "O" type O N // @describe describe-O "O"
type P = struct{N} // @describe describe-P "N" type P = struct{ N } // @describe describe-P "N"
type U = undefined // @describe describe-U "U" type U = undefined // @describe describe-U "U"
type _ = undefined // @describe describe-undefined "undefined" type _ = undefined // @describe describe-undefined "undefined"

View File

@ -35,7 +35,7 @@ func main() {
case chA2 <- &a2: // @peers peer-send-chA' "<-" case chA2 <- &a2: // @peers peer-send-chA' "<-"
} }
for _ = range chA { for range chA {
} }
close(chA) // @peers peer-close-chA "chA" close(chA) // @peers peer-close-chA "chA"

View File

@ -88,11 +88,7 @@ func initTemplates(base string) error {
var err error var err error
dirListTemplate, err = template.ParseFiles(filepath.Join(base, "templates/dir.tmpl")) dirListTemplate, err = template.ParseFiles(filepath.Join(base, "templates/dir.tmpl"))
if err != nil { return err
return err
}
return nil
} }
// renderDoc reads the present file, gets its template representation, // renderDoc reads the present file, gets its template representation,

View File

@ -294,7 +294,7 @@ func compareTool() {
} }
cmdS := append([]string{cmd[0], extra}, cmd[1:]...) cmdS := append([]string{cmd[0], extra}, cmd[1:]...)
outfile, ok = cmpRun(true, cmdS) outfile, _ = cmpRun(true, cmdS)
fmt.Fprintf(os.Stderr, "\n%s\n", compareLogs(outfile)) fmt.Fprintf(os.Stderr, "\n%s\n", compareLogs(outfile))
os.Exit(2) os.Exit(2)

View File

@ -770,7 +770,7 @@ func (p *exporter) rawByte(b byte) {
// tracef is like fmt.Printf but it rewrites the format string // tracef is like fmt.Printf but it rewrites the format string
// to take care of indentation. // to take care of indentation.
func (p *exporter) tracef(format string, args ...interface{}) { func (p *exporter) tracef(format string, args ...interface{}) {
if strings.IndexAny(format, "<>\n") >= 0 { if strings.ContainsAny(format, "<>\n") {
var buf bytes.Buffer var buf bytes.Buffer
for i := 0; i < len(format); i++ { for i := 0; i < len(format); i++ {
// no need to deal with runes // no need to deal with runes

View File

@ -435,7 +435,7 @@ func init() {
func init() { func init() {
// Regression test for SSA renaming bug. // Regression test for SSA renaming bug.
var ints []int var ints []int
for _ = range "foo" { for range "foo" {
var x int var x int
x++ x++
ints = append(ints, x) ints = append(ints, x)

View File

@ -182,7 +182,7 @@ func filterInfo(args []string, info *PageInfo) {
// Does s look like a regular expression? // Does s look like a regular expression?
func isRegexp(s string) bool { func isRegexp(s string) bool {
return strings.IndexAny(s, ".(|)*+?^$[]") >= 0 return strings.ContainsAny(s, ".(|)*+?^$[]")
} }
// Make a regular expression of the form // Make a regular expression of the form

View File

@ -38,7 +38,7 @@ func Style(s string) template.HTML {
// font returns s with font indicators turned into HTML font tags. // font returns s with font indicators turned into HTML font tags.
func font(s string) string { func font(s string) string {
if strings.IndexAny(s, "[`_*") == -1 { if !strings.ContainsAny(s, "[`_*") {
return s return s
} }
words := split(s) words := split(s)