Skip to content

Commit

Permalink
Added method stubs for unsupported OSes (#83)
Browse files Browse the repository at this point in the history
- Added method stubs to enable compilation for operating systems that are not
  supported by gosigar. All methods return `ErrNotImplemented` on these unsupported
  operating systems.
- FreeBSD returns `ErrNotImplemented` for `ProcTime.Get`.
- OpenBSD returns `ErrNotImplemented` for `ProcTime.Get` instead of `nil`.
- Remove NetBSD build from sigar_unix.go as it is not supported by gosigar.
  • Loading branch information
kvch authored and andrewkroh committed Nov 16, 2017
1 parent 306d519 commit 8620c67
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
5 changes: 5 additions & 0 deletions sigar_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package gosigar

import (
"io/ioutil"
"runtime"
"strconv"
"strings"
"unsafe"
Expand Down Expand Up @@ -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}
}
2 changes: 1 addition & 1 deletion sigar_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 35 additions & 0 deletions sigar_stub.go
Original file line number Diff line number Diff line change
@@ -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}
}
2 changes: 1 addition & 1 deletion sigar_unix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2012 VMware, Inc.

// +build darwin freebsd linux netbsd
// +build darwin freebsd linux

package gosigar

Expand Down

0 comments on commit 8620c67

Please sign in to comment.