sbconv

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 2 Imported by: 1

README

sbconv

Go Report Card

sbconv implements high-performance conversions between string and byte slice. It also provides deep copy function of both string and byte slice.

Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) (s string)

BytesToString converts a string to a byte slice.

This is a shallow copy, means that the returned string reuse the underlying array in byte slice, it's your responsibility to keep the input byte slice survive until you don't access the string anymore.

func BytesToStringNew

func BytesToStringNew(b []byte) (s string)

BytesToStringNew converts a byte slice to a new string. (Deep copy)

This function is used in case you want get a fresh version of string converted from the input byte slice, the returned string is a real string, this means the data field on this string is read only.

func DeepCopyBytes

func DeepCopyBytes(b []byte) []byte

DeepCopyBytes returns a deep copy of the input byte slice.

func DeepCopyString

func DeepCopyString(s string) string

DeepCopyString returns a deep copy of the input string.

This function is used in case of the input string is converted from BytesToString, this means it is not a real string, but share an underlying array with a byte slice, use this function to create a real string.

func StringToBytes

func StringToBytes(s string) (b []byte)

StringToBytes converts a string to a byte slice.

This is a shallow copy, means that the returned byte slice reuse the underlying array in string, so you can't change the returned byte slice in any situations.

func StringToBytesNew

func StringToBytesNew(s string) []byte

StringToBytesNew converts a string to a new byte slice.

The returned byte slice can be modified, it is actually a new byte slice, and it's content equal to the input string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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