syscall_netbsd_test.go 629 B

1234567891011121314151617181920
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package unix_test
  5. // stringsFromByteSlice converts a sequence of attributes to a []string.
  6. // On NetBSD, each entry consists of a single byte containing the length
  7. // of the attribute name, followed by the attribute name.
  8. // The name is _not_ NULL-terminated.
  9. func stringsFromByteSlice(buf []byte) []string {
  10. var result []string
  11. i := 0
  12. for i < len(buf) {
  13. next := i + 1 + int(buf[i])
  14. result = append(result, string(buf[i+1:next]))
  15. i = next
  16. }
  17. return result
  18. }