bytes

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pad

func Pad(data []byte, paddingSize int) []byte

Pad returns a buffer of the original data with padded trailing 0s of length of given paddingSize

Example
package main

import (
	"bytes"
	"fmt"

	byteUtil "github.com/taubyte/tau/utils/slices/bytes"
)

func main() {
	padSize := 5
	data := []byte("hello world")

	paddedData := byteUtil.Pad(data, padSize)

	data = append(data, make([]byte, padSize)...)
	if !bytes.Equal(data, paddedData) {
		return
	}

	fmt.Println(len(paddedData))
}
Output:
16

func PadLCM

func PadLCM(data []byte, lcm int) []byte

PadLCM returns a buffer with length of the Least Common Multiple of the given lcm value with the original data with padded trailing 0s

Example
package main

import (
	"bytes"
	"fmt"

	byteUtil "github.com/taubyte/tau/utils/slices/bytes"
)

func main() {
	lcm := 5
	data := []byte("hello world")

	paddedData := byteUtil.PadLCM(data, lcm)

	data = append(data, make([]byte, 4)...)
	if !bytes.Equal(data, paddedData) {
		return
	}

	fmt.Println(len(paddedData))
}
Output:
15

func StripPadding

func StripPadding(data []byte) []byte

StripPadding returns a buffer of the data stripped of all trailing 0s

Types

This section is empty.

Jump to

Keyboard shortcuts

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