Closed mchtech closed 4 years ago
How do you change file perms on Windows, then?
golang does not support chmod
(*File).Chmod
on Windows (so far) and ioutil.TempFile
always creates file with 0600.
So, one solution is to create the tmpfile with specified FilePerm
directly.
os.Chmod works fine on Windows, it just requires a restricted set of file modes. If you're using diskv on Windows, you can change diskv.FilePerm to one of those supported modes.
@mchtech Will that solve your problem?
It seems a problem of golang 😂
os.Chmod works fine on Windows, but (*File).Chmod will return syscall.EWINDOWS.
on Windows:
Does os.Chmod still return an error when you use one of the supported FileModes listed in the documentation?
I just tested it on Windows:
os.Chmod works fine on Windows and does not return any error but (*File).Chmod not
So, another solution is to change f.Chmod(perm)
to os.Chmod(f.Name(), perm)
OK, I believe this is safe.
https://github.com/golang/go/blob/bba88467f86472764a656e61f5f3265ed6853692/src/syscall/syscall_windows.go#L1094
os.Chmod always return syscall.EWINDOWS error on Windows.