path := "rename-after-open"
fd, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
if err != nil { ... }
err = os.Rename(path_a, path_b) // or os.Remove(path)
if err != nil { ... } // sharing violation
fd.Close()path := "rename-after-open"
fd, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
if err != nil { ... }
err = os.Rename(path_a, path_b) // or os.Remove(path)
if err != nil { ... } // sharing violation
fd.Close()path := "rename-after-open"
fd, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
if err != nil { ... }
err = os.Rename(path_a, path_b) // or os.Remove(path)
if err != nil { ... } // sharing violation
fd.Close()[Sorry to keep re-posting this; I'm keeping it visible for infrequent readers]
Microsoft recommends changing syscall.Open() for GOOS=windows to fix this. Pls reply if you know of existing apps that rely on it.This code fails with a "sharing violation" on Windows. That behavior is undocumented in package "os".path := "rename-after-open" fd, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600) if err != nil { ... } err = os.Rename(path_a, path_b) // or os.Remove(path) if err != nil { ... } // sharing violation fd.Close()In this issue, Microsoft suggested that Go on Windows switch to Unix-like behavior:
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1587c3db-4ce5-4572-bbb4-ed43c183d290%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.