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" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // The parse tree walkers are all methods of this type. | 82 // The parse tree walkers are all methods of this type. |
83 type File struct { | 83 type File struct { |
84 pkg *Package | 84 pkg *Package |
85 fset *token.FileSet | 85 fset *token.FileSet |
86 name string | 86 name string |
87 content []byte | 87 content []byte |
88 file *ast.File | 88 file *ast.File |
89 b bytes.Buffer // for use by methods | 89 b bytes.Buffer // for use by methods |
90 | 90 |
91 // The last "String() string" method receiver we saw while walking. | 91 // The last "String() string" method receiver we saw while walking. |
92 » // This is used by | 92 » // This is used by the recursiveStringer method in print.go. |
93 lastStringerReceiver *ast.Object | 93 lastStringerReceiver *ast.Object |
94 } | 94 } |
95 | 95 |
96 func main() { | 96 func main() { |
97 flag.Usage = Usage | 97 flag.Usage = Usage |
98 flag.Parse() | 98 flag.Parse() |
99 | 99 |
100 // If a check is named explicitly, turn off the 'all' flag. | 100 // If a check is named explicitly, turn off the 'all' flag. |
101 for name, ptr := range report { | 101 for name, ptr := range report { |
102 if name != "all" && *ptr { | 102 if name != "all" && *ptr { |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 func (f *File) walkRangeStmt(n *ast.RangeStmt) { | 481 func (f *File) walkRangeStmt(n *ast.RangeStmt) { |
482 checkRangeLoop(f, n) | 482 checkRangeLoop(f, n) |
483 } | 483 } |
484 | 484 |
485 // gofmt returns a string representation of the expression. | 485 // gofmt returns a string representation of the expression. |
486 func (f *File) gofmt(x ast.Expr) string { | 486 func (f *File) gofmt(x ast.Expr) string { |
487 f.b.Reset() | 487 f.b.Reset() |
488 printer.Fprint(&f.b, f.fset, x) | 488 printer.Fprint(&f.b, f.fset, x) |
489 return f.b.String() | 489 return f.b.String() |
490 } | 490 } |
LEFT | RIGHT |