path/filepath: document that WalkDir calls fs.WalkDirFunc with platform-specific paths #52812
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
The function
filepath.WalkDir
uses the callbackfs.WalkDirFunc
.Within
path/filepath
, paths generally use the slash separator of the host platform, so theroot
parameter tofilepath.WalkDir
is clearly a platform-specific path.However, it wasn't obvious to me upon reading the documentation whether the path passed to the WalkDirFunc was a platform-specific path or used
/
as the path separator. In fact, all the paths use the platform separator, but I had to read the code to be sure. Here are some reasons I thought theWalkDirFunc
path might be/
-separated:Other types/functions inside
io/fs
, such asfs.FS
, use/
-separated paths.When the same callback function
fs.WalkDirFunc
is called viafs.WalkDir
(rather thanfilepath.WalkDir
) it sees/
-separated paths.The
fs.WalkDirFunc
documentation mentions/
-separated paths:(I believe that on Windows, if this is coming from
filepath.WalkDir
, then it would bedir\a
rather thandir/a
.)I think the documentation of
filepath.WalkDir
and/orfs.WalkDirFunc
could be clearer on this point./cc @rsc who wrote most of this stuff as part of io/fs for Go 1.16.
The text was updated successfully, but these errors were encountered: