I'm using the reasonably new FileSystem style to do the usual directory walk processing every file in the usual recursive manner. I can't figure out how to get the directory data (the path up to the last /) even though I can see it in the output.
I am missing the proper name of the getter, or perhaps a cast/type assertion Playground: https://go.dev/play/p/Fde-rAA5YZI The key code is fsys := os.DirFS(".") fs.WalkDir(fsys, ".", func(p string, d fs.DirEntry, err error) error { fmt.Printf("%s struct: %T %v\n", p, d, d) which prints "'p" the current file name and extension the type of the fs.DirEntry and then the fsDirEntry structure Something like this: csvtsd/csvtsd.go struct: *os.unixDirent &{../csvtsd csvtsd.go 0 <nil>} csvtsd/csvtsd_test.go struct: *os.unixDirent &{../csvtsd csvtsd_test.go 0 <nil>} csvtsd/go.mod struct: *os.unixDirent &{../csvtsd go.mod 0 <nil>} You can see that the "p" is typically the path and filename csvtsd/csvtsd.go the type is a *os.unixDirent and there are four fields in the Dirent, the path (up to the last /) the filename and extension, and two other fields. Thanks -- 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/99c9d821-be0e-4763-ab40-72e3af61c511n%40googlegroups.com.