FAQ
https://codereview.appspot.com/6905057/diff/3012/src/pkg/os/file_posix.go
File src/pkg/os/file_posix.go (right):

https://codereview.appspot.com/6905057/diff/3012/src/pkg/os/file_posix.go#newcode156
src/pkg/os/file_posix.go:156: if syscall.ImplementsUtimens {
I'm not sure I'm a fan of this Implements style, but I guess we do do it
in one other case, which I'd never seen before.

I would personally probably instead make a new nil-by-default func
variable in the os package like:

// chtimesNano if non-nil is an implementation of Chtimes
// that supports nanosecond resolution. If nil or the return
// value is errNoSys, a portable microsecond resolution implementation
// is used instead.
var chtimesNano func(string, time.Time, time.Time) error

... and then Chtime is:

func Chtimes(...) {
if chtimesNano != nil {
if err := chtimesNano(name, atime, mtime); err != errNoSys {
return err
}
}
... .
}

... and then make files like:

// +build linux,darwin

func init() {
chtimesNano = chtimes
}

func chtimes(...) {

}

... then you don't have to have a dummy stub syscall.Utimens on
operating systems which don't support it.

https://codereview.appspot.com/6905057/

Search Discussions

  • Russ Cox at Dec 10, 2012 at 6:07 pm
    It would be nice if we could avoid func init in package os if possible.
    We're already passing nanoseconds to syscall.Utimes. Can we fix
    syscall.Utimes on systems that support it to do something with the
    nanoseconds?
    Then package os doesn't need to change at all.
  • Brad Fitzpatrick at Dec 10, 2012 at 6:52 pm

    On Mon, Dec 10, 2012 at 1:07 PM, Russ Cox wrote:

    It would be nice if we could avoid func init in package os if possible.
    We're already passing nanoseconds to syscall.Utimes.

    No, looks like we're passing microseconds to syscall.Utimes.

    We can't change that without breaking the Go 1 contract.

    Can we fix
    syscall.Utimes on systems that support it to do something with the
    nanoseconds?
    Then package os doesn't need to change at all.
  • Russ Cox at Dec 10, 2012 at 6:38 pm
    Oh, I missed the syscall.NsecToTimeval.
    It seems fine to write a syscall.UtimesNano that just wraps
    syscall.Utimes on the unimplemented systems.
    syscall can do a little to be more regular across systems.

    Russ

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 10, '12 at 5:44p
activeDec 10, '12 at 6:52p
posts4
users2
websitegolang.org

2 users in discussion

Brad Fitzpatrick: 2 posts Russ Cox: 2 posts

People

Translate

site design / logo © 2022 Grokbase