Skip to content

Commit d661503

Browse files
authored
Merge pull request #1393 from tklauser/byteslicetostring
host: use unix.ByteSliceToString
2 parents d2a3bd8 + f9a5834 commit d661503

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

host/host_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func KernelVersionWithContext(ctx context.Context) (version string, err error) {
319319
if err != nil {
320320
return "", err
321321
}
322-
return string(utsname.Release[:bytes.IndexByte(utsname.Release[:], 0)]), nil
322+
return unix.ByteSliceToString(utsname.Release[:]), nil
323323
}
324324

325325
func getSlackwareVersion(contents []string) string {

host/host_posix.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
package host
55

6-
import (
7-
"bytes"
8-
9-
"golang.org/x/sys/unix"
10-
)
6+
import "golang.org/x/sys/unix"
117

128
func KernelArch() (string, error) {
139
var utsname unix.Utsname
1410
err := unix.Uname(&utsname)
15-
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), err
11+
if err != nil {
12+
return "", err
13+
}
14+
return unix.ByteSliceToString(utsname.Machine[:]), nil
1615
}

0 commit comments

Comments
 (0)