Skip to content

Commit

Permalink
Merge pull request #1393 from tklauser/byteslicetostring
Browse files Browse the repository at this point in the history
host: use unix.ByteSliceToString
  • Loading branch information
shirou committed Dec 10, 2022
2 parents d2a3bd8 + f9a5834 commit d661503
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion host/host_linux.go
Expand Up @@ -319,7 +319,7 @@ func KernelVersionWithContext(ctx context.Context) (version string, err error) {
if err != nil {
return "", err
}
return string(utsname.Release[:bytes.IndexByte(utsname.Release[:], 0)]), nil
return unix.ByteSliceToString(utsname.Release[:]), nil
}

func getSlackwareVersion(contents []string) string {
Expand Down
11 changes: 5 additions & 6 deletions host/host_posix.go
Expand Up @@ -3,14 +3,13 @@

package host

import (
"bytes"

"golang.org/x/sys/unix"
)
import "golang.org/x/sys/unix"

func KernelArch() (string, error) {
var utsname unix.Utsname
err := unix.Uname(&utsname)
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), err
if err != nil {
return "", err
}
return unix.ByteSliceToString(utsname.Machine[:]), nil
}

0 comments on commit d661503

Please sign in to comment.