Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidDelta = errors.New("delta: invalid format") ErrChecksum = errors.New("delta: checksum mismatch") )
Functions ¶
func Apply ¶
Apply reconstructs target data from source and delta. Variable naming follows fossil/src/delta.c for cross-reference:
cnt = count, offset = source offset, cmd = command byte
func Checksum ¶
Checksum computes Fossil's delta checksum, matching delta.c's checksum(). Sum of 4-byte big-endian words, with trailing bytes in big-endian position.
func Create ¶
Create generates a delta that transforms source into target. Variable naming follows fossil/src/delta.c for cross-reference:
nHash = NHASH, ei = entry index, ml = match length, tPos = target position, sOff = source offset
Example ¶
package main
import (
"fmt"
"github.com/danmestas/libfossil/internal/delta"
)
func main() {
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 := delta.Create(source, target)
// 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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.