mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
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:
@@ -1,4 +0,0 @@
|
||||
package marshal
|
||||
|
||||
// Stub to make the compiler happy in darwin (i.e. avoid "no buildable Go source
|
||||
// files in" error)
|
||||
@@ -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])
|
||||
}
|
||||
@@ -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])
|
||||
}
|
||||
Reference in New Issue
Block a user