bytestring

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: GPL-3.0 Imports: 1 Imported by: 3

README

ByteString

A Go library for converting strings to byte slices and vice versa without memory allocation.

Installation

To install the bytestring library, use the go get command:

go get github.com/AH-dark/bytestring

Usage

The bytestring library provides functions to efficiently convert strings to byte slices and vice versa without memory allocation.

Convert String to Bytes
import "github.com/AH-dark/bytestring"

s := "Hello, World!"
b := bytestring.StringToBytes(s)
Convert Bytes to String
import "github.com/AH-dark/bytestring"

b := []byte{72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33}
s := bytestring.BytesToString(b)

Running Tests

To run tests, use the go test command in the project directory:

go test -v

Also, you can run benchmarks:

go test -bench=. -benchmem

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

Types

This section is empty.

Jump to

Keyboard shortcuts

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