diff options
author | Mateusz Byczkowski <mbyczkowski@gmail.com> | 2017-02-02 10:51:24 -0800 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-02 19:51:24 +0100 |
commit | a3344f15a67a67ed65f228db49e74fd390852e77 (patch) | |
tree | a7c4e696164f7d0976efe65fa6a333927eb7217a /worktree_linux.go | |
parent | fa35e5c2372f8a103aa0ab8baa13116a25abd03a (diff) | |
download | go-git-a3344f15a67a67ed65f228db49e74fd390852e77.tar.gz |
Fix compile-time error on Windows (#251)
syscall.Stat_t it not defined on Windows platform, and hence go-git
won't compile on Windows. It's better to pass more generic output of FileInfo `Sys()`
(of type interface{}) to `fillSystemInfo` and handle type assertion
separately for each platform.
Diffstat (limited to 'worktree_linux.go')
-rw-r--r-- | worktree_linux.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/worktree_linux.go b/worktree_linux.go index fcec30a..ad271d0 100644 --- a/worktree_linux.go +++ b/worktree_linux.go @@ -10,11 +10,13 @@ import ( ) func init() { - fillSystemInfo = func(e *index.Entry, os *syscall.Stat_t) { - e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec)) - e.Dev = uint32(os.Dev) - e.Inode = uint32(os.Ino) - e.GID = os.Gid - e.UID = os.Uid + fillSystemInfo = func(e *index.Entry, sys interface{}) { + if os, ok := sys.(*syscall.Stat_t); ok { + e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec)) + e.Dev = uint32(os.Dev) + e.Inode = uint32(os.Ino) + e.GID = os.Gid + e.UID = os.Uid + } } } |