When writing a cross platform language, selecting if your code behavior should behave "native like" (as the system act on default) or "exactly the same os-agnostic" is a hard choice -
but this is not an option in this case
I assume that a code that writes a file and then delete it is a very common use for piping data (not sure if this is your use case, but a very common use)
So, lets assume my program is writing a file called "my.data", and then calls another program and does not wait for it to end (or the other program is already running in the background) , this program lets say uploads this file which takes 10 seconds (lets call this other program "uploader") .
When my program calls .Remove on Linux:
1. if anyone would "ls my.data" , he would not get results
2. uploader would continue to upload the data and when it closes the handle (assuming on other app still has a handle to this file) - the file would be "really gone" including space on disk.
in fact, during these 10 seconds there may be 10 (or more) uploaders uploading 10 diff files all called "my.data" at the point uploader started, and deleted since.
When my program calls .Remove on Windows(FILE_SHARE_DELETE is on):
1. if anyone would "dir my.data", he would not get results
2. uploader would receive an error telling it the file is removed (probably EOF).
So - using FILE_SHARE_DELETE would not gain consistency os-wide, and stop using default os behavior on the other hand.
lose-lose
so, no resolution?
There may be a resolution, paiing an _open_osfhandle() of the CreateFile to and _fdopen and thus using a file descriptor instead of a file handle.
But this is not a simple "add FILE_SHARE_DELETE flag when opening a file in go ", but a somewhat "larger" change (I had to implement one for interacting with a PTP file sharing service at the time PTP was a hit, this was not a 5 min task :) ) .
Hope that's a better explanation.