LEFT | RIGHT |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Vet is a simple checker for static errors in Go source code. | 5 // Vet is a simple checker for static errors in Go source code. |
6 // See doc.go for more information. | 6 // See doc.go for more information. |
7 package main | 7 package main |
8 | 8 |
9 import ( | 9 import ( |
10 "bytes" | 10 "bytes" |
11 "flag" | 11 "flag" |
12 "fmt" | 12 "fmt" |
13 "go/ast" | 13 "go/ast" |
14 "go/parser" | 14 "go/parser" |
| 15 "go/printer" |
15 "go/token" | 16 "go/token" |
16 "io" | 17 "io" |
17 "os" | 18 "os" |
18 "path/filepath" | 19 "path/filepath" |
19 "strconv" | 20 "strconv" |
20 "strings" | 21 "strings" |
21 ) | 22 ) |
22 | 23 |
23 var verbose = flag.Bool("v", false, "verbose") | 24 var verbose = flag.Bool("v", false, "verbose") |
24 var exitCode = 0 | 25 var exitCode = 0 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 for _, id := range field.Names { | 261 for _, id := range field.Names { |
261 f.walkMethod(id, field.Type.(*ast.FuncType)) | 262 f.walkMethod(id, field.Type.(*ast.FuncType)) |
262 } | 263 } |
263 } | 264 } |
264 } | 265 } |
265 | 266 |
266 // walkRangeStmt walks a range statement. | 267 // walkRangeStmt walks a range statement. |
267 func (f *File) walkRangeStmt(n *ast.RangeStmt) { | 268 func (f *File) walkRangeStmt(n *ast.RangeStmt) { |
268 checkRangeLoop(f, n) | 269 checkRangeLoop(f, n) |
269 } | 270 } |
| 271 |
| 272 // goFmt returns a string representation of the expression |
| 273 func (f *File) gofmt(x ast.Expr) string { |
| 274 f.b.Reset() |
| 275 printer.Fprint(&f.b, f.fset, x) |
| 276 return f.b.String() |
| 277 } |
LEFT | RIGHT |