Documentation
¶
Overview ¶
Package str provides unsafe, zero-allocation conversions between Go's string and []byte types. It is designed for use in performance-sensitive situations where minimizing memory allocations is essential.
Background ¶
Go's standard conversions between string and []byte are are straightforward, but they always allocate new memory and copy data. This ensures immutability and type safety, but can introduce overhead in high-performance code. This package provides unsafe alternatives to these conversions that avoid these allocations, allowing direct access to the underlying data.
Disclaimer ¶
Only use these functions if you fully understand the implications of them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnsafeBytes ¶
UnsafeBytes returns a byte slice from a string without allocation.
func UnsafeString ¶
UnsafeString returns a string from a byte slice without allocation.
Types ¶
This section is empty.