doc.go 3.1 KB

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