Skip to content

Conversation

@SteveRuble
Copy link

The Cache.FilePath method was using the Dirs method to find the directory for a given package path, but this can result in cache misses because the dirsCache may have been populated using a path pattern (e.g. ./...) that doesn't match the package directory derived from the file path provided. This can result in a confusing slowdown when you know the package directory is in the cache but Cache.FilePath still results in calls out to go list to find the directory.

The fix is to use the Dir method instead of Dirs to find the directory for a given package path. I'm assuming that there's no need to support path patterns in FilePath.

The `Cache.FilePath` method was using the `Dirs` method to find the directory for a given package path, but this can result in cache misses because the `dirsCache` may have been populated using a path pattern (e.g. `./...`) that doesn't match the package directory derived from the file path provided. This can result in a confusing slowdown when you know the package directory is in the cache but `Cache.FilePath` still results in calls out to `go list` to find the directory.

The fix is to use the `Dir` method instead of `Dirs` to find the directory for a given package path.
I'm assuming that there's no need to support path patterns in `FilePath`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant