I now have this working as I want using filepath/walk. But if I try to use a concurrent walk operation, like the one originally written by Michael T Jones, I get behavior that seems to treat any return of SkipDir as a fatal error and all walking stops. filepath/walk does not do this; it continues to the next target correctly.
I feel I'm missing something. Am I? On Friday, October 28, 2022 at 10:06:39 PM UTC-4 Robert Solomon wrote: > Thank you very much > > On Fri, Oct 28, 2022, 8:15 AM Marvin Renich <mr...@renich.org> wrote: > >> * Robert Solomon <drro...@gmail.com> [221028 07:36]: >> > On ubuntu 22.04, I would like the walk function to NOT follow symlinks >> to >> > other filesystems. The find command uses the -xdev switch to achieve >> this. >> > >> > How can I get walk to behave like the -xdev switch to find? >> >> On Linux: >> >> ---- getdevid_linux.go >> >> package main >> >> import ( >> "io/fs" >> "syscall" >> ) >> >> type DevId uint64 >> >> // GetDevice returns the Device ID on which the given file resides. >> func GetDevice(path string, fi fs.FileInfo) DevId { >> var stat = fi.Sys().(*syscall.Stat_t) >> return DevId(stat.Dev) >> } >> >> ---- >> >> Then before calling filepath.Walk, filepath.WalkDir (more efficient), or >> fs.WalkDir, obtain the device ID of the root. In the call to WalkDir, >> pass this device ID to your walk function: >> >> err = filepath.WalkDir(root, func(path string, d fs.DirEntry, err >> error) error { return MyWalkFn(devId, path, d, err) }) >> >> In MyWalkFn, use d to obtain the device ID of the current path, and >> return fs.SkipDir if the device IDs do not match. >> >> ...Marvin >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "golang-nuts" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/golang-nuts/sBHhJydS66w/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> golang-nuts...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/Y1vHqjKVfQqM3gZy%40basil.wdw >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/114c555c-34c9-49bf-9347-837f890eae2fn%40googlegroups.com.