Add a -source flag to cmd/vet that instructs
it to typecheck purely from source code.
Updates #16086
Fixes #19332
Change-Id: Ic83d0f14d5bb837a329d539b2873aeccdf7bf669
Reviewed-on: https://go-review.googlesource.com/37690
Reviewed-by: Rob Pike <r@golang.org>
any flag is explicitly set to false, only those tests are disabled. Thus -printf=true
runs the printf check, -printf=false runs all checks except the printf check.
+By default vet uses the object files generated by 'go install some/pkg' to typecheck the code.
+If the -source flag is provided, vet uses only source code.
+
Available checks:
Assembly declarations
var (
verbose = flag.Bool("v", false, "verbose")
+ source = flag.Bool("source", false, "import from source instead of compiled object files")
tags = flag.String("tags", "", "space-separated list of build tags to apply when parsing")
tagList = []string{} // exploded version of tags flag; set in main
)
func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) error {
if stdImporter == nil {
- stdImporter = importer.Default()
+ if *source {
+ stdImporter = importer.For("source", nil)
+ } else {
+ stdImporter = importer.Default()
+ }
inittypes()
}
pkg.defs = make(map[*ast.Ident]types.Object)