-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: os: add Lchtimes to change only a symlink's times without following it #30487
Comments
Thank you for the feature request @Isolus and welcome to the Go project! There exists I've tagged this as a proposal and it'll get reviewed over the cycle by others and myself too but for starters I shall kindly page @kevinburke @rsc @ianlancetaylor |
I think that a specialized operation like this, one that is not available at all on many systems, belongs in the golang.org/x/sys/unix package, not the os package. |
But isn't it a little unintuitive that Lstat (the no follow companion) to Stat is included in the os package. Therefore I can retrieve the times with the os package, but I can't write them? I'm currently adding tar archiver functionality to an application and everything but a Lchtimes (or Lutimes) function for symlink handling (i. e. Lchmod and Lstat) is there (in the standard library). So my first thought was that this function was just forgotten. |
It's a little unintuitive that there are operating systems that provide |
I agree with Ian that we should not pretend to support |
Change https://golang.org/cl/164662 mentions this issue: |
Add Lutimes wrapping UtimesNanoAt. Updates golang/go#30487 Change-Id: Ic5bb3b4d88be5806522eaef9bd9b8b0f5c1c8f42 Reviewed-on: https://go-review.googlesource.com/c/sys/+/164662 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
I see this was merged into x/sys/unix. That seems like the right place to stop. Package os is for generally portable things (despite our imperfect execution of that plan), and this is a very special case. |
Great, just need this function to implement the touch -h option. |
Looks like there's no way to change access and modification times of a symlink.
We only have os.Chtimes which follows the symlink.
Since there is os.Chown and os.Lchown to change the uid and gid, I think there should also be Lchtimes. The implementation can be similar to the one of os.Chtimes. (E. g. on linux only the flag AT_SYMLINK_NOFOLLOW has to be added.)
The text was updated successfully, but these errors were encountered: