mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.15k stars 338 forks source link

v4: all: consider io/fs changes to our APIs #630

Open mvdan opened 3 years ago

mvdan commented 3 years ago

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 faster filepath.WalkDir, and so on. At least, we should be able to make shfmt's directory walking faster (fewer stat calls), and possibly parts of expand and interp too.

mvdan commented 2 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.

mvdan commented 2 years ago

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.