go.tools/cmd/vet: add stable checks to doc.go

These are the simplest possible descriptions of each command.
They may be fleshed out later.

Fixes golang/go#7298.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/61480044
This commit is contained in:
Andrew Gerrand 2014-02-13 11:05:01 +11:00
Родитель 8c7a4539cd
Коммит 47596b4b81
1 изменённых файлов: 79 добавлений и 9 удалений

Просмотреть файл

@ -9,6 +9,11 @@ calls whose arguments do not align with the format string. Vet uses heuristics
that do not guarantee all reports are genuine problems, but it can find errors that do not guarantee all reports are genuine problems, but it can find errors
not caught by the compilers. not caught by the compilers.
Usage:
go tool vet [flag] [file.go ...]
go tool vet [flag] [directory ...] # Scan all .go files under directory, recursively
Its exit code is 2 for erroneous invocation of the tool, 1 if a Its exit code is 2 for erroneous invocation of the tool, 1 if a
problem was reported, and 0 otherwise. Note that the tool does not problem was reported, and 0 otherwise. Note that the tool does not
check every possible problem and depends on unreliable heuristics check every possible problem and depends on unreliable heuristics
@ -20,7 +25,9 @@ those identified by the flags are performed.
Available checks: Available checks:
1. Printf family, flag -printf 1. Printf family
Flag -printf
Suspicious calls to functions in the Printf family, including any functions Suspicious calls to functions in the Printf family, including any functions
with these names: with these names:
@ -37,7 +44,9 @@ complains about arguments that look like format descriptor strings.
It also checks for errors such as using a Writer as the first argument of It also checks for errors such as using a Writer as the first argument of
Printf. Printf.
2. Methods, flag -methods 2. Methods
Flag -methods
Non-standard signatures for methods with familiar names, including: Non-standard signatures for methods with familiar names, including:
Format GobEncode GobDecode MarshalJSON MarshalXML Format GobEncode GobDecode MarshalJSON MarshalXML
@ -45,21 +54,79 @@ Non-standard signatures for methods with familiar names, including:
UnmarshalJSON UnreadByte UnreadRune WriteByte UnmarshalJSON UnreadByte UnreadRune WriteByte
WriteTo WriteTo
3. Struct tags, flag -structtags 3. Struct tags
Flag -structtags
Struct tags that do not follow the format understood by reflect.StructTag.Get. Struct tags that do not follow the format understood by reflect.StructTag.Get.
4. Unkeyed composite literals, flag -composites 4. Unkeyed composite literals
Flag -composites
Composite struct literals that do not use the field-keyed syntax. Composite struct literals that do not use the field-keyed syntax.
5. Assembly declarations
Usage: Flag -asmdecl
go tool vet [flag] [file.go ...] Mismatches between assembly files and Go function declarations.
go tool vet [flag] [directory ...] # Scan all .go files under directory, recursively
The other flags are: 6. Useless assignments
Flag -assign
Check for useless assignments.
7. Atomic mistakes
Flag -atomic
Common mistaken usages of the sync/atomic package.
8. Build tags
Flag -buildtags
Badly formed or misplaced +build tags.
9. Copying locks
Flag -copylocks
Locks that are erroneously passed by value.
10. Nil function comparison
Flag -nilfunc
Comparisons between functions and nil.
11. Range loop variables
Flag -rangeloops
Incorrect uses of range loop variables in closures.
12. Unreachable code
Flag -unreachable
Unreachable code.
13. Shadowed variables
Flag -shadow=false (experimental; must be set explicitly)
Variables that may have been unintentionally shadowed.
Other flags
These flags configure the behavior of vet:
-all (default true)
Check everything; disabled if any explicit check is requested.
-v -v
Verbose mode Verbose mode
-printfuncs -printfuncs
@ -71,6 +138,9 @@ The other flags are:
if you have Warn and Warnf functions that take an if you have Warn and Warnf functions that take an
io.Writer as their first argument, like Fprintf, io.Writer as their first argument, like Fprintf,
-printfuncs=Warn:1,Warnf:1 -printfuncs=Warn:1,Warnf:1
-shadowstrict
Whether to be strict about shadowing; can be noisy.
-test
For testing only: sets -all and -shadow.
*/ */
package main package main