Merge pull request #1393 from tklauser/byteslicetostring

host: use unix.ByteSliceToString
pull/1398/head
shirou 2 years ago committed by GitHub
commit d661503ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 {

@ -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
}

Loading…
Cancel
Save