unsafeheader.go 913 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2020 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 unsafeheader contains header declarations for the Go runtime's
  5. // slice and string implementations.
  6. //
  7. // This package allows x/sys to use types equivalent to
  8. // reflect.SliceHeader and reflect.StringHeader without introducing
  9. // a dependency on the (relatively heavy) "reflect" package.
  10. package unsafeheader
  11. import (
  12. "unsafe"
  13. )
  14. // Slice is the runtime representation of a slice.
  15. // It cannot be used safely or portably and its representation may change in a later release.
  16. type Slice struct {
  17. Data unsafe.Pointer
  18. Len int
  19. Cap int
  20. }
  21. // String is the runtime representation of a string.
  22. // It cannot be used safely or portably and its representation may change in a later release.
  23. type String struct {
  24. Data unsafe.Pointer
  25. Len int
  26. }