On Thu, Oct 11, 2018 at 4:48 PM, Greg Saylor <greg.saylor....@gmail.com> wrote: > > In other programming languages (this is specific to Linux/Unix systems), in > the past to ensure security in the even of a program crash, we would do > something like: > > 1. Create a temporary file and squirrel away the file handle > 2. Unlink the temporary file by name > 3. Various functions would write stuff to the file > 4. If the programs completes to some successful state, create a hardlink to > the file handle with the final filename > > I'm finding this very difficult to do in Go, as there does not seem to be a > way to do #4. And this is a very important consideration for this piece of > the system. > > For example, os.Rename takes filenames as the old/new filename. > > I figured looking in that code might reveal something lower level that could > be used, which lead me to syscal_linuxl.Rename() > > That lead me to syscall_linux.RenameAt() > > Which led me to zsyscall_linux_amd64.go. > > .. at this point I got pretty lost on how to do any of this. _AT_FDCWD and > fishing around in what appears to be some pretty low-level internals of > Go... > > Is there some way to achieve this or a way that can ensure these files are > always removed if the program is kill -9'd, terminates from a panic, etc.
Can you show us how you do this in C? I expect that will point toward how to do it in Go. Ian -- 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. For more options, visit https://groups.google.com/d/optout.