()
| 60 | } |
| 61 | |
| 62 | func (b bsdSysctl) Value() (float64, error) { |
| 63 | var tmp32 uint32 |
| 64 | var tmp64 uint64 |
| 65 | var tmpf64 float64 |
| 66 | var err error |
| 67 | |
| 68 | switch b.dataType { |
| 69 | case bsdSysctlTypeUint32: |
| 70 | tmp32, err = unix.SysctlUint32(b.mib) |
| 71 | tmpf64 = float64(tmp32) |
| 72 | case bsdSysctlTypeUint64: |
| 73 | tmp64, err = unix.SysctlUint64(b.mib) |
| 74 | tmpf64 = float64(tmp64) |
| 75 | case bsdSysctlTypeCLong: |
| 76 | tmpf64, err = b.getCLong() |
| 77 | } |
| 78 | |
| 79 | if err != nil { |
| 80 | return 0, err |
| 81 | } |
| 82 | |
| 83 | if b.conversion != nil { |
| 84 | return b.conversion(tmpf64), nil |
| 85 | } |
| 86 | |
| 87 | return tmpf64, nil |
| 88 | } |
| 89 | |
| 90 | func (b bsdSysctl) getCLong() (float64, error) { |
| 91 | raw, err := unix.SysctlRaw(b.mib) |
no test coverage detected