OS specific syscall.Stat_t use into separate file
The use of Stat_t in request-example.go is unix specific and broke the
Windows OS builds. This is the minimal change to fix that.
This fixes #157.
diff --git a/request-example.go b/request-example.go
index 965db7e..0cb4616 100644
--- a/request-example.go
+++ b/request-example.go
@@ -11,7 +11,6 @@
"os"
"path/filepath"
"sync"
- "syscall"
"time"
)
@@ -187,7 +186,7 @@
func (f *memFile) ModTime() time.Time { return f.modtime }
func (f *memFile) IsDir() bool { return f.isdir }
func (f *memFile) Sys() interface{} {
- return &syscall.Stat_t{Uid: 65534, Gid: 65534}
+ return fakeFileInfoSys()
}
// Read/Write
diff --git a/request-stub.go b/request-stub.go
new file mode 100644
index 0000000..653dd37
--- /dev/null
+++ b/request-stub.go
@@ -0,0 +1,9 @@
+// +build !cgo,!plan9 windows android
+
+package sftp
+
+import "syscall"
+
+func fakeFileInfoSys() interface{} {
+ return &syscall.Stat_t{Uid: 65534, Gid: 65534}
+}
diff --git a/request-unix.go b/request-unix.go
new file mode 100644
index 0000000..d0df30f
--- /dev/null
+++ b/request-unix.go
@@ -0,0 +1,10 @@
+// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris
+// +build cgo
+
+package sftp
+
+import "syscall"
+
+func fakeFileInfoSys() interface{} {
+ return &syscall.Stat_t{Uid: 65534, Gid: 65534}
+}