1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
times
==========
[](https://godoc.org/github.com/djherbis/times)
[](https://github.com/djherbis/times/releases/latest)
[](LICENSE.txt)
[](https://travis-ci.org/djherbis/times)
[](https://coveralls.io/r/djherbis/times?branch=master)
[](https://goreportcard.com/report/github.com/djherbis/times)
[](https://sourcegraph.com/github.com/djherbis/times?badge)
Usage
------------
File Times for #golang
Go has a hidden time functions for most platforms, this repo makes them accessible.
```go
package main
import (
"log"
"github.com/djherbis/times"
)
func main() {
t, err := times.Stat("myfile")
if err != nil {
log.Fatal(err.Error())
}
log.Println(t.AccessTime())
log.Println(t.ModTime())
if t.HasChangeTime() {
log.Println(t.ChangeTime())
}
if t.HasBirthTime() {
log.Println(t.BirthTime())
}
}
```
Supported Times
------------
| | windows | linux | solaris | dragonfly | nacl | freebsd | darwin | netbsd | openbsd | plan9 |
|:-----:|:-------:|:-----:|:-------:|:---------:|:------:|:-------:|:----:|:------:|:-------:|:-----:|
| atime | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| mtime | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| ctime | ✓* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
| btime | ✓ | | | | | ✓ | ✓| ✓ |
* Windows XP does not have ChangeTime so HasChangeTime = false,
however Vista onward does have ChangeTime so Timespec.HasChangeTime() will
only return false on those platforms when the syscall used to obtain them fails.
* Also note, Get(FileInfo) will now only return values available in FileInfo.Sys(), this means Stat() is required to get ChangeTime on Windows
Installation
------------
```sh
go get github.com/djherbis/times
```
|