mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
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:
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 @@
|
|||||||
"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…
Reference in New Issue
Block a user