-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
embed: openFile should implement ReaderAt #57803
Comments
If the proposal is accepted, I can happily do the legwork on implementation and testing. Or delegate it to the Go team, whichever is more efficient (the burden of reviewing untrusted code is often higher than the implementation, but I've contributed a couple fixes before, so I'm already familiar with the process). |
My 2¢: We shouldn't promise that files from |
I'm fine with that, but we already promise to implement For the |
You're right, I missed that detail. Ah well. Probably not worth worrying about then. |
This seems completely reasonable. |
Should I do this, @rsc? |
This has not been accepted yet, but it is likely to be accepted. If you want to work on it, go ahead and mail a patch, but it won't be committed until the proposal is formally reviewed and accepted. Thanks. |
This proposal has been added to the active column of the proposals project |
SGTM! |
Based on the discussion above, this proposal seems like a likely accept. |
Change https://go.dev/cl/483235 mentions this issue: |
No change in consensus, so accepted. 🎉 |
Would it be possible to backport https://go-review.googlesource.com/c/go/+/483235 to the next go 1.20 release, or do we need to wait for go1.21? Thanks! |
this wouldn't meet the bar for backporting (major bugs with no workaround) |
Change https://go.dev/cl/499418 mentions this issue: |
For #57803 Change-Id: I8e33f4dd3fc3071bfbf4d2848faefbe8488f5742 Reviewed-on: https://go-review.googlesource.com/c/go/+/499418 TryBot-Bypass: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
embed.openFile
could trivially implementio.ReaderAt
.go/src/embed/embed.go
Lines 348 to 381 in 15605ca
That's the entire proposal.
Rationale
io.ReaderAt
can be emulated withio.ReadSeeker
, but this doesn't satisfy the goroutine safety ofio.ReaderAt
: “Clients of ReadAt can execute parallel ReadAt calls on the same input source.”This came up twice now on implementing
wazero
syscalls, that followpread
semantics: tetratelabs/wazero#967, and now tetratelabs/wazero#1037.It got its own mention in that project's design rationale.
It is also of note that
io.ReaderAt
is directly called out on thefs.File
documentation: A file may implement io.ReaderAt or io.Seeker as optimizations.The text was updated successfully, but these errors were encountered: