mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
Reuse the functions added for FreeBSD. Change-Id: Icf5bf65c82f91147659947f6ea296dd2555724a0 Reviewed-on: https://go-review.googlesource.com/128256 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
21 lines
629 B
Go
21 lines
629 B
Go
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package unix_test
|
|
|
|
// stringsFromByteSlice converts a sequence of attributes to a []string.
|
|
// On NetBSD, each entry consists of a single byte containing the length
|
|
// of the attribute name, followed by the attribute name.
|
|
// The name is _not_ NULL-terminated.
|
|
func stringsFromByteSlice(buf []byte) []string {
|
|
var result []string
|
|
i := 0
|
|
for i < len(buf) {
|
|
next := i + 1 + int(buf[i])
|
|
result = append(result, string(buf[i+1:next]))
|
|
i = next
|
|
}
|
|
return result
|
|
}
|