times

#golang file times (atime, mtime, ctime, btime)

  • Owner: djherbis/times
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

times

GoDoc
Release
Software License
Build Status
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"

  "gopkg.in/djherbis/times.v1"
)

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, js, :-----:, :-------:, :-----:, :-------:, :---------:, :------:, :-------:, :----:, :------:, :-------:, :-----:, :-----:, 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

go get gopkg.in/djherbis/times.v1

Main metrics

Overview
Name With Ownerdjherbis/times
Primary LanguageGo
Program languageGo (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2015-08-29 07:08:15
Pushed At2023-10-20 15:09:49
Last Commit At2023-10-03 17:12:34
Release Count10
Last Release Namev1.6.0 (Posted on )
First Release Namev0.9.0 (Posted on )
用户参与
Stargazers Count271
Watchers Count6
Fork Count29
Commits Count116
Has Issues Enabled
Issues Count7
Issue Open Count1
Pull Requests Count7
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private