-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imports: do less I/O finding the package name of an import
When goimports was run on a file like: package main import ( "example.net/foo" "example.net/bar" ) var _, _ = foo.Foo, bar.Bar ... even though there looks to be no work to do, it still needs to verify that "example.net/foo" is really package "foo" (even though it looks like it) and "example.net/bar" is really package "bar". (Packages in the standard library are hard-coded since the previous commit and not verified for consistency since they're always consistent) To do that verification for non-std packages, go/build.Import was being used before, but Import reads all files in the directory to make sure they're consistent. That's unnecessary. Instead, stop after the first file. If example.net/foo has foo.go with "package foo" and just_kidding.go with "package other", we never read that far to find the inconsistency. Oh well. Prefer speed. Updates golang/go#16367 Change-Id: I9fc3fefbee0e8a6bc287bf2a565257fb9523fd5c Reviewed-on: https://go-review.googlesource.com/24948 Reviewed-by: Josh Bleecher Snyder <[email protected]>
- Loading branch information
Showing
2 changed files
with
85 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters