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/*
6Vet examines Go source code and reports suspicious constructs, such as Printf
7calls whose arguments do not align with the format string. Vet uses heuristics
8that do not guarantee all reports are genuine problems, but it can find errors
9not caught by the compilers.
10
11Vet is normally invoked through the go command.
12This command vets the package in the current directory:
13
14	go vet
15
16whereas this one vets the packages whose path is provided:
17
18	go vet my/project/...
19
20Use "go help packages" to see other ways of specifying which packages to vet.
21
22Vet's exit code is non-zero for erroneous invocation of the tool or if a
23problem was reported, and 0 otherwise. Note that the tool does not
24check every possible problem and depends on unreliable heuristics,
25so it should be used as guidance only, not as a firm indicator of
26program correctness.
27
28To list the available checks, run "go tool vet help":
29
30	appends          check for missing values after append
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 //go:build and // +build directives
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	defers           report common mistakes in defer statements
40	directive        check Go toolchain directives such as //go:debug
41	errorsas         report passing non-pointer or non-error values to errors.As
42	framepointer     report assembly that clobbers the frame pointer before saving it
43	httpresponse     check for mistakes using HTTP responses
44	ifaceassert      detect impossible interface-to-interface type assertions
45	loopclosure      check references to loop variables from within nested functions
46	lostcancel       check cancel func returned by context.WithCancel is called
47	nilfunc          check for useless comparisons between functions and nil
48	printf           check consistency of Printf format strings and arguments
49	shift            check for shifts that equal or exceed the width of the integer
50	sigchanyzer      check for unbuffered channel of os.Signal
51	slog             check for invalid structured logging calls
52	stdmethods       check signature of methods of well-known interfaces
53	stringintconv    check for string(int) conversions
54	structtag        check that struct field tags conform to reflect.StructTag.Get
55	testinggoroutine report calls to (*testing.T).Fatal from goroutines started by a test
56	tests            check for common mistaken usages of tests and examples
57	timeformat       check for calls of (time.Time).Format or time.Parse with 2006-02-01
58	unmarshal        report passing non-pointer or non-interface values to unmarshal
59	unreachable      check for unreachable code
60	unsafeptr        check for invalid conversions of uintptr to unsafe.Pointer
61	unusedresult     check for unused results of calls to some functions
62
63For details and flags of a particular check, such as printf, run "go tool vet help printf".
64
65By default, all checks are performed.
66If any flags are explicitly set to true, only those tests are run.
67Conversely, if any flag is explicitly set to false, only those tests are disabled.
68Thus -printf=true runs the printf check,
69and -printf=false runs all checks except the printf check.
70
71For information on writing a new check, see golang.org/x/tools/go/analysis.
72
73Core flags:
74
75	-c=N
76	  	display offending line plus N lines of surrounding context
77	-json
78	  	emit analysis diagnostics (and errors) in JSON format
79*/
80package main
81