github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/vet/doc.go (about) 1 // Copyright 2010 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 7 Vet examines Go source code and reports suspicious constructs, such as Printf 8 calls whose arguments do not align with the format string. Vet uses heuristics 9 that do not guarantee all reports are genuine problems, but it can find errors 10 not caught by the compilers. 11 12 Its exit code is 2 for erroneous invocation of the tool, 1 if a 13 problem was reported, and 0 otherwise. Note that the tool does not 14 check every possible problem and depends on unreliable heuristics 15 so it should be used as guidance only, not as a firm indicator of 16 program correctness. 17 18 By default all checks are performed, but if explicit flags are provided, only 19 those identified by the flags are performed. 20 21 Available checks: 22 23 1. Printf family, flag -printf 24 25 Suspicious calls to functions in the Printf family, including any functions 26 with these names: 27 Print Printf Println 28 Fprint Fprintf Fprintln 29 Sprint Sprintf Sprintln 30 Error Errorf 31 Fatal Fatalf 32 Panic Panicf Panicln 33 If the function name ends with an 'f', the function is assumed to take 34 a format descriptor string in the manner of fmt.Printf. If not, vet 35 complains about arguments that look like format descriptor strings. 36 37 It also checks for errors such as using a Writer as the first argument of 38 Printf. 39 40 2. Methods, flag -methods 41 42 Non-standard signatures for methods with familiar names, including: 43 Format GobEncode GobDecode MarshalJSON MarshalXML 44 Peek ReadByte ReadFrom ReadRune Scan Seek 45 UnmarshalJSON UnreadByte UnreadRune WriteByte 46 WriteTo 47 48 3. Struct tags, flag -structtags 49 50 Struct tags that do not follow the format understood by reflect.StructTag.Get. 51 52 4. Untagged composite literals, flag -composites 53 54 Composite struct literals that do not use the type-tagged syntax. 55 56 57 Usage: 58 59 go tool vet [flag] [file.go ...] 60 go tool vet [flag] [directory ...] # Scan all .go files under directory, recursively 61 62 The other flags are: 63 -v 64 Verbose mode 65 -printfuncs 66 A comma-separated list of print-like functions to supplement 67 the standard list. Each entry is in the form Name:N where N 68 is the zero-based argument position of the first argument 69 involved in the print: either the format or the first print 70 argument for non-formatted prints. For example, 71 if you have Warn and Warnf functions that take an 72 io.Writer as their first argument, like Fprintf, 73 -printfuncs=Warn:1,Warnf:1 74 75 */ 76 package main