I have a scenario where I need to check permissions of files (and folders) in Windows, without attempting to read them.
As a further complication, these files are on a network share.
To do so, I run os.Stat()
on the file and then check f.Mode().Perm()
. The issue is, even for files that I do not have access, this API call shows that I do indeed have access.
During testing of this error, I logged the permissions, then I tried to read the file (in production this program will not be reading the file). I get an error stating that I don’t have access to read the file, as I expect.
My question is, other than attempting to read/write a file and checking the error, is there a reliable way to check real permissions in Go under Windows?
Thanks for your time!