Description
As described in the discussion of https://go.dev/cl/508506, simplifying gopathwalk to use filepath.WalkDir had the unfortunate consequence of significantly slowing performance when starting from a cold module cache, as would be the case when running goimports from the command line. This is also very noticeable when gopls is initially started. On my laptop, with a 19GB module cache, warming up goimports went from ~6s to ~30s.
Because this latency was already a concern for gopls (see #44863), I don't think we can afford such a significant regression. With that said, the regression is probably possible to mitigate with alternative concurrency strategies. A benchmark is added in https://go.dev/cl/561436 which we can use for revisiting the simplification. For now, I think we need to temporarily revert CL 508506.
CC @bcmills