mirror of
https://github.com/golang/sys.git
synced 2026-02-09 04:06:04 +03:00
Change-Id: I0d439b5c59c79594c6ecfebe0375971e1344cc09 Reviewed-on: https://go-review.googlesource.com/c/sys/+/213400 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
20 lines
511 B
Go
20 lines
511 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 Darwin, each entry is a NULL-terminated string.
|
|
func stringsFromByteSlice(buf []byte) []string {
|
|
var result []string
|
|
off := 0
|
|
for i, b := range buf {
|
|
if b == 0 {
|
|
result = append(result, string(buf[off:i]))
|
|
off = i + 1
|
|
}
|
|
}
|
|
return result
|
|
}
|