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
x/tools/txtar: implement fs.FS #44158
Comments
SGTM. No need for a proposal. |
I’m on paternity leave now so I can only type with my left thumb during the day. (Gotta keep the bottle in my right hand.) I’ll try to send out a CL as soon as I can but it may not be until next month. |
Hate to be a broken record on this particular thing, but I'm pretty sure thanks to #40067, this can't happen until The (This could certainly be implemented in some other repo/module and work fine, though. golang-migrate has done this for now to support |
For this kind of use--implementing the interface--the relevant code can be protected by a build tag. |
Yes, that's correct. My interpretation of Ian's comment was that all of the bits and pieces that make up the IMO #40067 is going to gate quite a few users for the much-anticipated |
Yes, that's correct. It is unfortunately not possible to implement the Probably the cleanest solution in the short term is to put the |
Even a new package won't work, it'd need to be another module; #40067 affects modules, as the tooling refuses to continue once it detects that a module it's downloaded contains a package it can't resolve. |
@zikaeroh, I believe you are mistaken. Neither |
It would mean that users would be unable to run |
I was basing my experience on #40067 (comment), but I can see how that list of packages means I was indirectly importing it. I'll have to make a minimal example to look at the edge cases. I guess this is overall better than "it's impossible", but this behavior is a little infectious in nature and non-obvious that there's a different set of checks that aren't aware of build tags or new packages. |
The separate package thing will only work if nothing imports it, at which point I may as well just publish the package on my own account and wait until Go 1.16 is the lowest supported version to comeback and add it to x/tools. |
I couldn't quite tell what the status was here, and I wanted this for my own purposes, so I put together an extremely quick and dirty bridge package: https://github.com/josharian/txtarfs. I look forward to txtar directly supporting fs.FS in the future. |
I was wrong about it infecting the whole module (@bcmills was of course correct); |
Oh, I'm a liar, that was added to an existing package and I didn't notice when I read the CL, so it doesn't serve as a working example (and probably should be added to #40067...). |
With #44557 fixed and now backported, nothing stops adding io/fs and embed to existing packages anymore (other than waiting for patch release adoption). |
If it's possible to make this change now, @josharian do you want to just submit your txtarfs as a CL? |
It's kind of a hack, and it allocates unnecessarily, and it creates a new thing instead of just using the txtar directly as an fs.FS. So I think it's not worth upstreaming—it'd be better to do properly. |
I started working on an implementation, and getting the directory stuff right basically requires reimplementing MapFS, so I don't think there's actually that much to be gained by doing it "right". I would change |
I see. Pity. Feel free to steal code wholesale from txtarfs as you please. If you want to credit me, you can add a "Co-authored-by: " trailer to the git commit. |
Now I'm looking at it more, and the directory stuff is a pain, but not insurmountable, and having the |
Fixes #44158 From implementation copied with permission from https://github.com/josharian/txtarfs/blob/main/txtarfs_test.go golang/go#44158 (comment) Co-authored-by: josharian
I added a co-authored credit, but that seems to have made the CLA bot angry |
Fixes #44158 From implementation copied with permission from https://github.com/josharian/txtarfs/blob/main/txtarfs_test.go golang/go#44158 (comment) Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com>
Fixes #44158 From implementation copied with permission from https://github.com/josharian/txtarfs/blob/main/txtarfs_test.go golang/go#44158 (comment) Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com>
Fixes golang/go#44158 From implementation copied with permission from https://github.com/josharian/txtarfs/blob/main/txtarfs_test.go golang/go#44158 (comment)
Okay, I opened a PR without the Co-authored-by comment and now it seems to be accepting the CLA. |
Fixes golang/go#44158 From implementation copied with permission from https://github.com/josharian/txtarfs/blob/main/txtarfs_test.go golang/go#44158 (comment)
The implementation would be pretty simple, and it would let you use txtar format for templates and http.FileServers.
The text was updated successfully, but these errors were encountered: