arrays

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceToArray

func SliceToArray(slice []byte, length int) interface{}

SliceToArray Converts an bytes slice to an array of size "length" and returns an interface with the result

In Go, arrays have a fixed size that must be known at compile time, which makes converting a slice to an array of variable size directly not possible. However, and using reflection we can create an array with the appropiate size at runtime.

params
 slice contains the bytes slice
 length sets the size of the resulting array

returns
 an interface{} with the fixed size array

Types

This section is empty.

Jump to

Keyboard shortcuts

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