unsafe_disabled.go 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //go:build !(amd64 || arm64 || ppc64le || riscv64) || nounsafe || purego || appengine
  2. package le
  3. import (
  4. "encoding/binary"
  5. )
  6. // Load8 will load from b at index i.
  7. func Load8[I Indexer](b []byte, i I) byte {
  8. return b[i]
  9. }
  10. // Load16 will load from b at index i.
  11. func Load16[I Indexer](b []byte, i I) uint16 {
  12. return binary.LittleEndian.Uint16(b[i:])
  13. }
  14. // Load32 will load from b at index i.
  15. func Load32[I Indexer](b []byte, i I) uint32 {
  16. return binary.LittleEndian.Uint32(b[i:])
  17. }
  18. // Load64 will load from b at index i.
  19. func Load64[I Indexer](b []byte, i I) uint64 {
  20. return binary.LittleEndian.Uint64(b[i:])
  21. }
  22. // Store16 will store v at b.
  23. func Store16(b []byte, v uint16) {
  24. binary.LittleEndian.PutUint16(b, v)
  25. }
  26. // Store32 will store v at b.
  27. func Store32(b []byte, v uint32) {
  28. binary.LittleEndian.PutUint32(b, v)
  29. }
  30. // Store64 will store v at b.
  31. func Store64(b []byte, v uint64) {
  32. binary.LittleEndian.PutUint64(b, v)
  33. }