Sorry, I did not intend to open a new thread.
I don't know how to answer you about the actual contents of the
directory of interest. It's my c:\users\rob\Documents directory.
There are a lot of files there. I'm writing my own version of the dir
command, one that will sort and behave exactly as I want. I decided to
experiment w/ the new library definitions; and discovered that DirEntry
is not a replacement for FileInfo. I thought that was the intent of the
Go team, but I guess did not understand. In my code I went back to
using Lstat, and instead of ioutil.ReadDir, I now use
f, err := os.Open(directoryname)
if err != nil { blah blah blah}
files, err := f.Readdir(0)
if err != nil { blah blah blah}
And this works for me.
--rob solomon
On 3/11/21 4:00 PM, Axel Wagner wrote:
I don't understand why you opened a new thread. But FWIW, it would
still be useful to know
a) what the actual contents of the directory are you are globbing
b) which of those file names is then giving you an error
c) and which specific call is returning that error.
Your message "Unexpected error from os.DirEntry" is confusing, as the
only method of os.DirEntry that could return an error, hardcodes that
error to be nil, as far as I can tell:
https://github.com/golang/go/blob/b3896fc331c36a539f825f1f656cef3f9cdffd3f/src/os/dir_windows.go#L68
<https://github.com/golang/go/blob/b3896fc331c36a539f825f1f656cef3f9cdffd3f/src/os/dir_windows.go#L68>
In the other thread, I also tried to provide a plausible explanation
from the limited info - it seems strange that you are globbing for
*.txt files and then call ReadDir with those filenames. Have you read
that message?
On Thu, Mar 11, 2021 at 9:31 PM rob <drrob...@fastmail.com
<mailto:drrob...@fastmail.com>> wrote:
As the subject line says, this is on windows.
I'm getting the file not found error for every file returned by
the glob function.
I guess I misunderstood the purpose of ReadDir, and I really need
to call os.Lstat to retrieve the directory information for each
individual file that matches the glob pattern on widows 10.
I'll check, but I'm able to call os.ReadDir on an individual file
on Ubuntu 20.04. I'll confirm when I get home that I'm getting a
FileInfo structure returned from this routine
--
rob
drrob...@fastmail.com <mailto:drrob...@fastmail.com>
--
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
<mailto:golang-nuts%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/137cb626-90f1-455e-b0aa-7a6d476e3813%40www.fastmail.com
<https://groups.google.com/d/msgid/golang-nuts/137cb626-90f1-455e-b0aa-7a6d476e3813%40www.fastmail.com>.
--
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/f677bd54-cb56-3c9c-8ea4-f89e45ceadb1%40fastmail.com.