unsafeconv

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes added in v2.3.0

func Bytes[S ~string | ~[]byte](s S) []byte

Bytes returns a []byte view of s without allocation for any string- or byte-slice-backed type. It relies on string and slice headers both starting with the data pointer (guaranteed by the gc runtime layout, and the same assumption UnsafeString makes). When S's underlying type is string, the result aliases immutable memory and must only be read.

func UnsafeBytes

func UnsafeBytes(s string) []byte

UnsafeBytes returns a byte slice view of s without allocation.

func UnsafeString

func UnsafeString(b []byte) string

UnsafeString returns a string view of b without allocation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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