Closed mvdan closed 6 years ago
This is somewhat related to issue #2 in that maybe we could use the write.File name to be the WriteFile replacement.
In general, I like the idea. I’ll keep notes when switching projects to go-write to confirm where WriteFile would be usable.
More bikeshedding - if you make write.File
be ioutil.WriteFile
, then you could have the existing constructor be write.StartFile
.
I’ve renamed the package to “renameio”. Now, adding a WriteFile method mirroring ioutil.WriteFile seems like a straight-forward thing to do :)
Moving from Twitter at https://twitter.com/mvdan_/status/1057289983340544002.
https://golang.org/pkg/io/ioutil/#WriteFile suffices for quite a lot of simple cases where one wants to create or overwrite a file with some contents. That generally is four lines of code, including error handling.
Comparatively, the simplest
TempFile
example takes nine lines, and requires a defer. This makes it less suitable for these simpler use cases, and makes replacingioutil.WriteFile
with this package harder.It shouldn't be necessary to strictly stick to
ioutil.WriteFile
's signature, but one advantage of doing that would be the simplicity of porting code over.