Debian Codegraph @

libgo/go/cmd/vet/doc.go

raw
1 // Copyright 2018 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 Vet is normally invoked through the go command.
13 This command vets the package in the current directory:
14
15 go vet
16
17 whereas this one vets the packages whose path is provided:
18
19 go vet my/project/...
20
21 Use "go help packages" to see other ways of specifying which packages to vet.
22
23 Vet's exit code is non-zero for erroneous invocation of the tool or if a
24 problem was reported, and 0 otherwise. Note that the tool does not
25 check every possible problem and depends on unreliable heuristics,
26 so it should be used as guidance only, not as a firm indicator of
27 program correctness.
28
29 To list the available checks, run "go tool vet help":
30
31 asmdecl report mismatches between assembly files and Go declarations
32 assign check for useless assignments
33 atomic check for common mistakes using the sync/atomic package
34 bools check for common mistakes involving boolean operators
35 buildtag check that +build tags are well-formed and correctly located
36 cgocall detect some violations of the cgo pointer passing rules
37 composites check for unkeyed composite literals
38 copylocks check for locks erroneously passed by value
39 httpresponse check for mistakes using HTTP responses
40 loopclosure check references to loop variables from within nested functions
41 lostcancel check cancel func returned by context.WithCancel is called
42 nilfunc check for useless comparisons between functions and nil
43 printf check consistency of Printf format strings and arguments
44 shift check for shifts that equal or exceed the width of the integer
45 stdmethods check signature of methods of well-known interfaces
46 structtag check that struct field tags conform to reflect.StructTag.Get
47 tests check for common mistaken usages of tests and examples
48 unmarshal report passing non-pointer or non-interface values to unmarshal
49 unreachable check for unreachable code
50 unsafeptr check for invalid conversions of uintptr to unsafe.Pointer
51 unusedresult check for unused results of calls to some functions
52
53 For details and flags of a particular check, such as printf, run "go tool vet help printf".
54
55 By default, all checks are performed.
56 If any flags are explicitly set to true, only those tests are run.
57 Conversely, if any flag is explicitly set to false, only those tests are disabled.
58 Thus -printf=true runs the printf check,
59 and -printf=false runs all checks except the printf check.
60
61 For information on writing a new check, see golang.org/x/tools/go/analysis.
62
63 Core flags:
64
65 -c=N
66 display offending line plus N lines of surrounding context
67 -json
68 emit analysis diagnostics (and errors) in JSON format
69
70 */
71 package main