Linux command
go-vet 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Check current package
go vet
Check specific package
go vet [package]
Check all packages
go vet ./...
Run specific analyzer
go vet -[analyzer] [package]
List analyzers
go vet -help
说明
go vet examines Go source code and reports suspicious constructs that the compiler does not catch. It finds bugs like incorrect printf format strings, unreachable code, and misuse of sync primitives. The tool runs multiple analyzers that check for common mistakes. It is part of the standard quality assurance workflow alongside testing and formatting.
参数
- -json
- JSON output.
- -c _N_
- Display offending line with N lines of context.
- -v
- Verbose output.
- -n
- Print commands but do not run them.
- -x
- Print the commands as they are executed.
- -vettool _prog_
- Select a different analysis tool.
- -tags _TAGS_
- Build tags.
FAQ
What is the go-vet command used for?
go vet examines Go source code and reports suspicious constructs that the compiler does not catch. It finds bugs like incorrect printf format strings, unreachable code, and misuse of sync primitives. The tool runs multiple analyzers that check for common mistakes. It is part of the standard quality assurance workflow alongside testing and formatting.
How do I run a basic go-vet example?
Run `go vet` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -json do in go-vet?
JSON output.