usrlz

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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