Presenter: Oliver Stenbom
Liveblogger: Issac Trotts
When the core of a language fails you, and you can’t remove a file, how can you fix it? Oliver will share his contribution journey from bug to merge in a crucial part of Golang: the os package. Discover how Golang manages platform independence and how even novices can contribute Unix system calls.
Lots hidden between the lines, like what can I offer to Go, what can it contribute to me, and the contribution experience.
At one point, long file paths with many nested directories could not be removed with
os.RemoveAll. Such long names are created by accident or malicious intent.
Our first attempt at solving this was to shell out to
rm -rf, but it wasn’t such a great solution. In addition to not working on Windows, it didn’t tell us
anything about what caused the problem.
The real cause was that
Remove were all failing with long filenames.
Removeat solves this problem.
Their signature looks like for example
Removeat(directory, path) where
directory is a file descriptor.
We did this in own code base and it solved our problem, but we wanted to help the Go community so we decided to contribute our fix to the Go standard library.
We created an issue, with a snippet of code reproducing the problem etc.
RemoveAllwas simple, platform independent
*atsys call version is unix specific.
Use the more general solution if you can, make it more specific if you have to
Removeare all system calls under the hood.
A system call is
*atnot on Go on all systems
Ian Taylor said to implement the basic version, then let the community help you with the rest. Trying to do it all at once makes it less likely for your contribution to succeed.
Long and meandering path to getting the solution merged. Problem, solution, development, discussion, improvement, merge, revert, merge.
the os package
rm -rf: 46 additions
Local solution without shelling out: 226 additions.
Solution contributed to Go standard library: over 600 additions.