fdelta

package module
v0.0.0-...-1d797d7 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-2-Clause Imports: 1 Imported by: 1

README

Delta compression algorithm written in Go

Fossil achieves efficient storage and low-bandwidth synchronization through the use of delta-compression. Instead of storing or transmitting the complete content of an artifact, fossil stores or transmits only the changes relative to a related artifact.

Other implementations:

Install
$ go get -u github.com/shadowspore/fossil-delta
Example
package main

import (
	"fmt"

	fdelta "github.com/shadowspore/fossil-delta"
)

func main() {
	origin := []byte("abcdefghijklmnopqrstuvwxyz1234567890")
	target := []byte("abcdefghijklmnopqrstuvwxyz0987654321")

	// Create delta
	delta := fdelta.Create(origin, target)

	// Create target by patching origin with delta
	patched, err := fdelta.Apply(origin, delta)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Origin: `%s`\n", origin)
	fmt.Printf("Target: `%s`\n", target)
	fmt.Printf("Delta : `%s`\n", delta)
	fmt.Printf("Patch : `%s`\n", patched)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(origin, delta []byte) ([]byte, error)

Apply delta to origin byte slice.

func Create

func Create(origin, target []byte) []byte

Create delta between origin and target byte slices.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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