Debian Codegraph @

/

debian golang-github-djherbis-times 1.6.0-1debian golang-github-djherbis-times-dev gomod github.com/djherbis/times debiangogoinimakefilemarkdownshellyaml 37 files · 214 symbols
View dependency graph

Depends on

README (full)

times

GoDoc Release Software License go test Coverage Status Go Report Card Sourcegraph

Usage

File Times for #golang

Go has a hidden time functions for most platforms, this repo makes them accessible.

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

windowslinuxsolarisdragonflynaclfreebsddarwinnetbsdopenbsdplan9jsaix
atime✓✓✓✓✓✓✓✓✓✓✓✓
mtime✓✓✓✓✓✓✓✓✓✓✓✓
ctime✓*✓✓✓✓✓✓✓✓✓✓
btime✓✓*✓✓✓
  • Linux btime requires kernel 4.11 and filesystem support, so HasBirthTime = false. Use Timespec.HasBirthTime() to check if file has birth time. Get(FileInfo) never returns 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

go get -u github.com/djherbis/times
dir .github/
dir debian/
dir example/
file LICENSE
file README.md
file bench_test.go
file ctime_windows.go
file go.mod
file go.sum
file js.cover.dockerfile
file js.cover.sh
file linux.cover.dockerfile
file linux.cover.sh
file times.go
file times_aix.go
file times_darwin.go
file times_dragonfly.go
file times_freebsd.go
file times_js.go
file times_linux.go
file times_linux_test.go
file times_nacl.go
file times_netbsd.go
file times_openbsd.go
file times_plan9.go
file times_solaris.go
file times_test.go
file times_wasip1.go
file times_windows.go
file times_windows_test.go
file use_generic_stat.go
file util_test.go