diff --git a/go/types/api.go b/go/types/api.go index ae53f7c9..5344a39e 100644 --- a/go/types/api.go +++ b/go/types/api.go @@ -113,6 +113,10 @@ type Config struct { // If Sizes != nil, it provides the sizing functions for package unsafe. // Otherwise &StdSizes{WordSize: 8, MaxAlign: 8} is used instead. Sizes Sizes + + // If DisableUnusedImportCheck is set, packages are not checked + // for unused imports. + DisableUnusedImportCheck bool } // DefaultImport is the default importer invoked if Config.Import == nil. diff --git a/go/types/check.go b/go/types/check.go index 5b30a300..b48a8abf 100644 --- a/go/types/check.go +++ b/go/types/check.go @@ -233,7 +233,9 @@ func (check *Checker) Files(files []*ast.File) (err error) { check.initOrder() - check.unusedImports() + if !check.conf.DisableUnusedImportCheck { + check.unusedImports() + } // perform delayed checks for _, f := range check.delayed {