-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathver_openbsd.go
48 lines (40 loc) · 904 Bytes
/
ver_openbsd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package osinfo
import (
"os/exec"
"runtime"
)
// GetVersion OpenBSD returns version info
// fetching info for this os is fairly simple
// version information is all fetched via `uname`
// Returns:
// - r.Runtime
// - r.Arch
// - r.Name
// - r.Version
// - r.BSD.Kernel
// - r.BSD.PkgManager
func GetVersion() *Release {
info := &Release{
Runtime: runtime.GOOS,
Arch: runtime.GOARCH,
Name: "unknown",
Version: "unknown",
BSD: bsdRelease{
Kernel: "unknown",
PkgManager: "pkg_add",
},
}
fullName, err := exec.Command("uname", "-sr").Output()
if err == nil {
info.Name = cleanString(string(fullName))
}
version, err := exec.Command("uname", "-r").Output()
if err == nil {
info.Version = cleanString(string(version))
}
kernel, _ := exec.Command("uname", "-v").Output()
if err == nil {
info.BSD.Kernel = cleanString(string(kernel))
}
return info
}