Open mvdan opened 3 years ago
I'm leaving this issue open for v4. For example, 4c03448abb155f8800e5fb3b79c48668f1015049 left a TODO for expand.Config, since its API came before the fs package. We can't break v3 APIs, and I don't think I'm in a rush to deprecate many v3 APIs just for the sake of small performance gains.
The fileutil addition in the commit above is slightly different, because the performance does matter for shfmt.
Notes for future reference: we tried to add an io/fs handler to the interpreter in v3 in https://github.com/mvdan/sh/pull/799, but we gave up due to the shortcomings of the current io/fs API - it doesn't support writing files, and it doesn't support a root FS on Windows, in the sense of being able to use absolute paths with their volume names.
Once Go 1.17 is out, we'll be able to drop support for Go 1.15. Then we'll be able to use the new APIs in Go 1.16, such as the
fs.FS
interface, the fasterfilepath.WalkDir
, and so on. At least, we should be able to makeshfmt
's directory walking faster (fewer stat calls), and possibly parts ofexpand
andinterp
too.