Skip to content
go-libfossil Artifact [5fb43d3bf3]
Login

Artifact [5fb43d3bf3]

Artifact 5fb43d3bf395e0c90bba6b8d5dd4d77ec65aa89cf850db4f942ea13b5153a655:


package delta_test

import (
	"fmt"

	"github.com/danmestas/go-libfossil/internal/delta"
)

func ExampleCreate() {
	source := []byte("the quick brown fox jumps over the lazy dog\n")
	target := []byte("the quick brown fox leaps over the lazy dog\n")

	d, err := delta.Create(source, target)
	if err != nil {
		fmt.Println("error:", err)
		return
	}

	// Delta is smaller than storing the full target.
	fmt.Printf("delta smaller: %v\n", len(d) < len(target))

	// Apply reconstructs the target from source + delta.
	reconstructed, err := delta.Apply(source, d)
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	fmt.Print(string(reconstructed))
	// Output:
	// delta smaller: true
	// the quick brown fox leaps over the lazy dog
}