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>
This commit is contained in:
Tobias Klauser 2022-06-01 15:03:00 +02:00 committed by Brad Fitzpatrick
parent 2a61261a5a
commit 3a926348a4
2 changed files with 3 additions and 12 deletions

View File

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

View File

@ -14,6 +14,7 @@
"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")
} }