usrlz

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToBytes

func ToBytes[T any, P *T](obj P) []byte

ToBytes converts an object of type T, passed as a pointer P, into a byte slice. It uses reflection and unsafe package to achieve this conversion.

Type Parameters: - T: The type of the object. - P: The pointer type to the object (should be *T).

Parameters: - obj: The object to convert, passed as a pointer of type P.

Returns: - A byte slice representing the raw bytes of the object.

Panics: - If the object is not addressable (cannot take the address of the value).

Note:

  • The object must be passed as a pointer, and it must be addressable.
  • This function uses unsafe operations, which can lead to undefined behavior if not used carefully. Ensure that the object remains valid for the duration of the byte slice usage.

Types

This section is empty.

Jump to

Keyboard shortcuts

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