diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ca054c7..44fd7ce60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,18 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Added method stubs to enable compilation for operating systems that are not + supported by gosigar. All methods return `ErrNotImplemented` on these unsupported + operating systems. #83 +- FreeBSD returns `ErrNotImplemented` for `ProcTime.Get`. #83 ### Changed +- OpenBSD returns `ErrNotImplemented` for `ProcTime.Get` instead of `nil`. #83 ### Deprecated ### Removed +- Remove NetBSD build from sigar_unix.go as it is not supported by gosigar. #83 ## [0.5.0] diff --git a/sigar_freebsd.go b/sigar_freebsd.go index 602b4a0aa..0a31d0887 100644 --- a/sigar_freebsd.go +++ b/sigar_freebsd.go @@ -4,6 +4,7 @@ package gosigar import ( "io/ioutil" + "runtime" "strconv" "strings" "unsafe" @@ -106,3 +107,7 @@ func parseCpuStat(self *Cpu, line string) error { self.Idle, _ = strtoull(fields[4]) return nil } + +func (self *ProcTime) Get(pid int) error { + return ErrNotImplemented{runtime.GOOS} +} diff --git a/sigar_openbsd.go b/sigar_openbsd.go index abf967b83..4f1383a6b 100644 --- a/sigar_openbsd.go +++ b/sigar_openbsd.go @@ -370,7 +370,7 @@ func (self *ProcMem) Get(pid int) error { } func (self *ProcTime) Get(pid int) error { - return nil + return ErrNotImplemented{runtime.GOOS} } func (self *ProcExe) Get(pid int) error { diff --git a/sigar_stub.go b/sigar_stub.go new file mode 100644 index 000000000..18beb3cf8 --- /dev/null +++ b/sigar_stub.go @@ -0,0 +1,35 @@ +// +build !darwin,!freebsd,!linux,!openbsd,!windows + +package gosigar + +import ( + "runtime" +) + +func (c *Cpu) Get() error { + return ErrNotImplemented{runtime.GOOS} +} + +func (l *LoadAverage) Get() error { + return ErrNotImplemented{runtime.GOOS} +} + +func (m *Mem) Get() error { + return ErrNotImplemented{runtime.GOOS} +} + +func (s *Swap) Get() error { + return ErrNotImplemented{runtime.GOOS} +} + +func (f *FDUsage) Get() error { + return ErrNotImplemented{runtime.GOOS} +} + +func (p *ProcTime) Get(int) error { + return ErrNotImplemented{runtime.GOOS} +} + +func (self *FileSystemUsage) Get(path string) error { + return ErrNotImplemented{runtime.GOOS} +} diff --git a/sigar_unix.go b/sigar_unix.go index 985c3720f..f11c156f5 100644 --- a/sigar_unix.go +++ b/sigar_unix.go @@ -1,6 +1,6 @@ // Copyright (c) 2012 VMware, Inc. -// +build darwin freebsd linux netbsd +// +build darwin freebsd linux package gosigar