unsafeslice

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2015 License: MIT Imports: 2 Imported by: 0

README

Unsafe zero-copy slice casts for Go

Convenience functions for casting raw bytes to typed arrays without copying.

Usage:

b := []byte{1, 2, 3, 4}
v := unsafeslice.Uint32SliceFromByteSlice(b)

Documentation

Index

Constants

View Source
const (
	Uint64Size = 8
	Uint32Size = 4
	Uint16Size = 2
	Uint8Size  = 1
)

Variables

This section is empty.

Functions

func ByteSliceFromStructSlice

func ByteSliceFromStructSlice(s interface{}) []byte

func Int16SliceFromByteSlice

func Int16SliceFromByteSlice(b []byte) []int16

func Int32SliceFromByteSlice

func Int32SliceFromByteSlice(b []byte) []int32

func Int64SliceFromByteSlice

func Int64SliceFromByteSlice(b []byte) []int64

func Int8SliceFromByteSlice

func Int8SliceFromByteSlice(b []byte) []int8

func StructSliceFromByteSlice

func StructSliceFromByteSlice(b []byte, out interface{})

Create a slice of structs from a slice of bytes.

var v []Struct
StructSliceFromByteSlice(bytes, &v)

Elements in the byte array must be padded correctly. See unsafe.AlignOf, et al.

func Uint16SliceFromByteSlice

func Uint16SliceFromByteSlice(b []byte) []uint16

func Uint32SliceFromByteSlice

func Uint32SliceFromByteSlice(b []byte) []uint32

func Uint64SliceFromByteSlice

func Uint64SliceFromByteSlice(b []byte) []uint64

func Uint8SliceFromByteSlice

func Uint8SliceFromByteSlice(b []byte) []uint8

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL