...
1
2
3
4
5
6
7 package osinfo
8
9 import "golang.org/x/sys/unix"
10
11
12 func Version() (string, error) {
13 var uts unix.Utsname
14 if err := unix.Uname(&uts); err != nil {
15 return "", err
16 }
17
18 sysname := unix.ByteSliceToString(uts.Sysname[:])
19 release := unix.ByteSliceToString(uts.Release[:])
20 version := unix.ByteSliceToString(uts.Version[:])
21 machine := unix.ByteSliceToString(uts.Machine[:])
22
23 return sysname + " " + release + " " + version + " " + machine, nil
24 }
25
View as plain text