djherbis / times Goto Github PK
View Code? Open in Web Editor NEW#golang file times (atime, mtime, ctime, btime)
License: MIT License
#golang file times (atime, mtime, ctime, btime)
License: MIT License
Hello,
I have a usecase where i'm already calling Stat on the files on wich i have to also get the times for.
Would it be possible to add another set of Stat and LStat wich also return the Fileinfo they used?
Thanks!
I can help with the PR if you think this would be usefull.
If the platform specific stat fails, the error is silently swallowed and a regular (i.e noctime) stat result is returned:
Lines 12 to 17 in fd6b033
This can cause unexpected panics if the caller assumes the return value will be the platform-specific result:
panic: ctime not available
goroutine 108 [running]:
github.com/djherbis/times.noctime.ChangeTime(0xc000be0730, 0x0, 0x0)
github.com/djherbis/[email protected]/times.go:68 +0x45
github.com/tmm1/myApp/app.createdAtFor(0xc002758075, 0x10, 0xc00138bd51, 0xf3, 0x30)
I have a need to update times on a file when I run and produce a log file. That is:
Basically, I want to be able to rotate old logs but preserve their time. While times
allows me to look up the times, it does not allow me to update the times. Has this been considered?
Any thoughts on using os.Lstat
instead of os.Stat
? Stat
tries to follow symlinks, giving the information about the target, as opposed to the file itself. This means:
Or maybe have it as an option?
Get(os.FileInfo) opens the file on Win 7+ in order to obtain the ChangeTime via a file handle (which is not directly available on the Go struct). This is both expensive, and potentially problematic (my tests so far show that it doesn't seem to affect any of the file times, but I don't really want to do excessive actions behind the scenes).
I'm considering turning this off for Get and only having it active for Stat. I think this makes sense since Get should not have to Open the file, and Get should only make use of the data inside os.FileInfo.
I'm considering making this a version change as well.
Any suggestions? Complaints? Comments?
that is, similar to the FileInfo Sys() interface, which i can access from f := os.Open(); f.Stat()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.