Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pad ¶
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/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 ¶
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/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 ¶
StripPadding returns a buffer of the data stripped of all trailing 0s
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.