Simplify Utsname string conversion

Use Utsname from golang.org/x/sys/unix which contains byte array
instead of int8/uint8 array members. This allows to simplify the string
conversions of these members and the marshal.FromUtsname functions are
no longer needed.
This commit is contained in:
Tobias Klauser
2017-11-01 09:54:58 +01:00
parent ac6a629aa2
commit 89f3ce2e64
6 changed files with 18 additions and 59 deletions

View File

@@ -1,4 +0,0 @@
package marshal
// Stub to make the compiler happy in darwin (i.e. avoid "no buildable Go source
// files in" error)

View File

@@ -1,17 +0,0 @@
// +build !arm
package marshal
// FromUtsname reads the C-strings from syscall.Utsname and transforms them to Go
// strings
func FromUtsname(ca [65]int8) string {
s := make([]byte, len(ca))
var lens int
for ; lens < len(ca); lens++ {
if ca[lens] == 0 {
break
}
s[lens] = uint8(ca[lens])
}
return string(s[0:lens])
}

View File

@@ -1,15 +0,0 @@
package marshal
// FromUtsname reads the C-strings from syscall.Utsname and transforms them to Go
// strings
func FromUtsname(ca [65]uint8) string {
s := make([]byte, len(ca))
var lens int
for ; lens < len(ca); lens++ {
if ca[lens] == 0 {
break
}
s[lens] = uint8(ca[lens])
}
return string(s[0:lens])
}