rogpeppe / go-internal

Selected Go-internal packages factored out from the standard library
BSD 3-Clause "New" or "Revised" License
825 stars 67 forks source link

robustio: add package #203

Closed eandre closed 6 months ago

eandre commented 1 year ago

This adds the robustio package from golang.org/x/tools/internal/robustio which in turn is copied from cmd/go/internal/robustio.

It would be great to add this to go-internal as we've sort of been standardizing on this repo for a lot of go-internal utility packages. I could of course maintain this myself but I hope you consider it for inclusion. The errors it "fixes" (papers over) are quite common when dealing with temporary files on Windows.

mvdan commented 1 year ago

Historically we've only copied packages from Go's main repository, not x/tools, so I would lean towards including https://pkg.go.dev/cmd/go/internal/robustio instead of https://pkg.go.dev/golang.org/x/tools/internal/robustio.

Also note that the x/tools API is slightly larger, with https://pkg.go.dev/golang.org/x/tools/internal/robustio#GetFileID. I would argue that not including that is a good thing, as it seems like an opaque and low level API that doesn't seem useful on its own.

rogpeppe commented 6 months ago

Superceded by #239 (thanks for the suggestion @eandre!)