replacement for filepath.HasPrefix?

519 views
Skip to first unread message

Jochen Voss

unread,
May 16, 2024, 7:15:45 AM5/16/24
to golang-nuts
Dear all,

filepath.HasPrefix is deprecated, because it doesn't alway work.  What would be a replacement for this function, which at least respects path boundaries, and maybe also ignores case when needed?

All the best,
Jochen

peterGo

unread,
May 16, 2024, 7:36:16 AM5/16/24
to golang-nuts

Jochen,

"the first step is to define exactly what the function should do."

path/filepath: fix HasPrefix #18358

Peter

Jason E. Aten

unread,
May 21, 2024, 8:50:47 PM5/21/24
to golang-nuts
When I needed to follow symlinks and exclude application-specific directories, I ended
up copying and customizing Walk() and walk() from the filepath package. They are
short and it was a straightforward to adapt them to my needs.

https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/path/filepath/path.go;l=476
Reply all
Reply to author
Forward
0 new messages