Skip to content

Commit 18194f4

Browse files
committed
Document diff subpackage in README
1 parent 119e840 commit 18194f4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ reader, _ := archives.OpenWithPrefix("pkg.tgz", f, "package/")
5555
// files are now accessible without the package/ prefix
5656
```
5757

58+
### Comparing versions
59+
60+
The `diff` subpackage compares two archives and produces unified diffs. It classifies each file as added, deleted, modified, or binary, and includes line-level diff output for text files.
61+
62+
```go
63+
import "github.com/git-pkgs/archives/diff"
64+
65+
result, _ := diff.Compare(oldReader, newReader)
66+
for _, f := range result.Files {
67+
fmt.Printf("%s %s (+%d -%d)\n", f.Type, f.Path, f.LinesAdded, f.LinesDeleted)
68+
if f.Diff != "" {
69+
fmt.Println(f.Diff)
70+
}
71+
}
72+
```
73+
5874
## Supported formats
5975

6076
- `.zip`, `.jar`, `.whl`, `.nupkg`, `.egg` (ZIP-based)

0 commit comments

Comments
 (0)