GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - balacode/go-delta: go-delta - A Go package and utility to generate and apply binary delta updates.

BranchesTags
Open more actions menu

Latest commit

 

History

170 Commits
170 Commits

Folders and files

NameName
Last commit message
Last commit date
delu
delu
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
delta.go
delta.go
 
 
delta_apply.go
delta_apply.go
 
 
delta_apply_test.go
delta_apply_test.go
 
 
delta_bytes.go
delta_bytes.go
 
 
delta_dump.go
delta_dump.go
 
 
delta_go_string.go
delta_go_string.go
 
 
delta_internal.go
delta_internal.go
 
 
delta_load.go
delta_load.go
 
 
experiment_test.go
experiment_test.go
 
 
func.go
func.go
 
 
func_test.go
func_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
index_map.go
index_map.go
 
 
integrated_test.go
integrated_test.go
 
 
lorem_ipsum.txt
lorem_ipsum.txt
 
 
make.go
make.go
 
 
make_test.go
make_test.go
 
 
module.go
module.go
 
 

Repository files navigation

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

About

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

Topics

binarydelta-compressiondiffdiffinggolanggolang-package

Resources

Readme
MIT license
Activity

Stars

34 stars

Watchers

0 watching

Forks

6 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.