commit | 1f7065f429b5b53c5029e3a6c198aab00f6a32c4 | [log] [tgz] |
---|---|---|
author | Nathan Leiby <nathan.leiby@clever.com> | Fri Apr 26 06:25:00 2019 |
committer | GitHub <noreply@github.com> | Fri Apr 26 06:25:00 2019 |
tree | 7a24c8c6d4fd3aa9075b7c69c5609f63d85dd661 | |
parent | 03c80ab4baa86dbaac3e191372e989027ee2a2e5 [diff] | |
parent | 79c2d9b582a95dddef45f85caafd5afc70102ee9 [diff] |
Merge pull request #15 from isacikgoz/add_doc_and_go_mod Add doc and go mod
DiffParser is a Golang package which parse's a git diff.
go get github.com/waigani/diffparser
package main import ( "fmt" "github.com/waigani/diffparser" ) // error handling left out for brevity func main() { byt, _ := ioutil.ReadFile("example.diff") diff, _ := diffparser.Parse(string(byt)) // You now have a slice of files from the diff, file := diff.Files[0] // diff hunks in the file, hunk := file.Hunks[0] // new and old ranges in the hunk newRange := hunk.NewRange // and lines in the ranges. line := newRange.Lines[0] }
See diffparser_test.go for further examples.