bytesconv

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Str

func Bytes2Str(b []byte) string

Bytes2Str Zero-copy convert from byte slice to a string see reflect.SliceHeader and reflect.StringHeader 理论上是 string(byte{"a","b"}) 的20倍速率

func Str2Bytes

func Str2Bytes(s string) []byte

Str2Bytes Convert different types to byte slice using types and functions in unsafe and reflect package(see reflect.SliceHeader and reflect.StringHeader). It has higher performance, but notice that it may be not safe when garbage collection happens.Use it when you need to temporary convert a long string to a byte slice and won't keep it for long time. 理论上与 []byte("string") 速度几乎是一致的

Types

This section is empty.

Jump to

Keyboard shortcuts

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