MCPcopy Index your code
hub / github.com/balacode/go-delta

github.com/balacode/go-delta @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
43 symbols 125 edges 17 files 41 documented · 95%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

go-delta - A Go package and utility to generate and apply binary delta updates.

Go Report Card Build Status Test Coverage Gitter chat godoc License: MIT

Suggestions:

  • Works best on text files, database dumps and any other files with lots of repeating patterns and few changes between updates.

  • Generating deltas of compressed files is not recommended because a small change in the source data can lead to lots of changes in the compressed result, so generating a delta update may give you only minimal size reduction.

  • Don't compress bytes returned by Delta.Bytes() because they are already compressed using ZLib compression.

  • Every delta update adds about 156 bytes for the source and target hashes and various lengths, so it is not recommended for very miniscule updates.

Demonstration:

package main

import (
    "fmt"
    "github.com/balacode/go-delta"
)

func main() {
    fmt.Print("Binary delta update demo:\n\n")

    // The original data (20 bytes):
    var source = []byte("quick brown fox, lazy dog, and five boxing wizards")
    fmt.Print("The original is:", "\n", string(source), "\n\n")

    // The updated data containing the original and new content (82 bytes):
    var target = []byte(
        "The quick brown fox jumps over the lazy dog. " +
        "The five boxing wizards jump quickly.",
    )
    fmt.Print("The update is:", "\n", string(target), "\n\n")

    var dbytes []byte
    {
        // Use Make() to generate a compressed patch from source and target
        var d = delta.Make(source, target)

        // Convert the delta to a slice of bytes (e.g. for writing to a file)
        dbytes = d.Bytes()
    }

    // Create a Delta from the byte slice
    var d = delta.Load(dbytes)

    // Apply the patch to source to get the target
    // The size of the patch is much shorter than target.
    var target2, err = d.Apply(source)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Print("Patched:", "\n", string(target2), "\n\n")
} //                                                                        main

Core symbols most depended-on inside this repo

makeHash
called by 10
func.go
Bytes
called by 9
delta_bytes.go
GoString
called by 5
delta_go_string.go
Make
called by 4
make.go
Apply
called by 3
delta_apply.go
makeMap
called by 3
index_map.go
write
called by 3
delta_internal.go
Dump
called by 2
delta_dump.go

Shape

Function 27
Method 11
Struct 4
TypeAlias 1

Languages

Go100%

Modules by API surface

func.go6 symbols
delta.go6 symbols
module.go4 symbols
index_map.go4 symbols
func_test.go4 symbols
experiment_test.go4 symbols
delu/main.go4 symbols
make.go2 symbols
make_test.go1 symbols
integrated_test.go1 symbols
delta_load.go1 symbols
delta_internal.go1 symbols

For agents

$ claude mcp add go-delta \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page