hostinfo: use ByteSliceToString from golang.org/x/sys/unix

Use unix.ByteSliceToString in osVersionFreebsd and osVersionLinux to
convert the Utsname.Release []byte field to string.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
pull/4755/head
Tobias Klauser 3 years ago committed by Brad Fitzpatrick
parent 2a61261a5a
commit 3a926348a4

@ -27,12 +27,7 @@ func osVersionFreebsd() string {
var attrBuf strings.Builder var attrBuf strings.Builder
attrBuf.WriteString("; version=") attrBuf.WriteString("; version=")
for _, b := range un.Release { attrBuf.WriteString(unix.ByteSliceToString(un.Release[:]))
if b == 0 {
break
}
attrBuf.WriteByte(byte(b))
}
attr := attrBuf.String() attr := attrBuf.String()
version := "FreeBSD" version := "FreeBSD"

@ -14,6 +14,7 @@ import (
"os" "os"
"strings" "strings"
"golang.org/x/sys/unix"
"tailscale.com/util/lineread" "tailscale.com/util/lineread"
"tailscale.com/version/distro" "tailscale.com/version/distro"
) )
@ -72,12 +73,7 @@ func osVersionLinux() string {
var attrBuf strings.Builder var attrBuf strings.Builder
attrBuf.WriteString("; kernel=") attrBuf.WriteString("; kernel=")
for _, b := range un.Release { attrBuf.WriteString(unix.ByteSliceToString(un.Release[:]))
if b == 0 {
break
}
attrBuf.WriteByte(byte(b))
}
if inContainer() { if inContainer() {
attrBuf.WriteString("; container") attrBuf.WriteString("; container")
} }

Loading…
Cancel
Save