{"id":23423763,"url":"https://github.com/zihuan-yan/go-git-diff","last_synced_at":"2026-01-22T20:32:26.446Z","repository":{"id":47495242,"uuid":"400733877","full_name":"zihuan-yan/go-git-diff","owner":"zihuan-yan","description":"go语言的git diff解析","archived":false,"fork":false,"pushed_at":"2022-06-21T05:23:26.000Z","size":22,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T16:43:37.408Z","etag":null,"topics":["diff","git","git-diff","git-difftool","gitdiff","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zihuan-yan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2021-08-28T07:45:32.000Z","updated_at":"2024-02-20T07:55:56.000Z","dependencies_parsed_at":"2022-09-04T07:23:08.914Z","dependency_job_id":null,"html_url":"https://github.com/zihuan-yan/go-git-diff","commit_stats":null,"previous_names":["lower-coder/go-git-diff"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zihuan-yan/go-git-diff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zihuan-yan%2Fgo-git-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zihuan-yan%2Fgo-git-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zihuan-yan%2Fgo-git-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zihuan-yan%2Fgo-git-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zihuan-yan","download_url":"https://codeload.github.com/zihuan-yan/go-git-diff/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zihuan-yan%2Fgo-git-diff/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28670381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T19:36:09.361Z","status":"ssl_error","status_checked_at":"2026-01-22T19:36:05.567Z","response_time":144,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diff","git","git-diff","git-difftool","gitdiff","go","golang"],"created_at":"2024-12-23T04:13:04.995Z","updated_at":"2026-01-22T20:32:26.425Z","avatar_url":"https://github.com/zihuan-yan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-git-diff [![CI](https://github.com/lower-coder/go-git-diff/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/lower-coder/go-git-diff/actions/workflows/go.yml) [![CI](https://github.com/lower-coder/go-git-diff/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/lower-coder/go-git-diff/actions/workflows/codeql-analysis.yml)\n\nA tool for developer to parse output of git diff command.\n\n## Usage\n\n- diff: A parser that parse output of git diff command to struct diff.\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"github.com/lower-coder/go-git-diff/diff\"\n)\n\nconst diffText = `diff --git a/file1 b/file1\nindex 504d2a1..50ccec3 100644\n--- a/file1\n+++ b/file1\n@@ -1,4 +1,4 @@\n+add a line\n some\n lines\n-in\n file1`\n\nfunc main() {\n\td := diff.NewDiff()\n\td.Parse(diffText)\n}\n\n/*\n{\n  \"files\": [\n    {\n      \"mode\": 2,\n      \"input\": {\n        \"source\": \"a/file1\",\n        \"target\": \"b/file1\"\n      },\n      \"metas\": [\n        {\n          \"meta_type\": \"index\",\n          \"content\": \"504d2a1..50ccec3 100644\"\n        }\n      ],\n      \"legends\": [\n        {\n          \"mark\": \"---\",\n          \"content\": \"a/file1\"\n        },\n        {\n          \"mark\": \"+++\",\n          \"content\": \"b/file1\"\n        }\n      ],\n      \"chunks\": [\n        {\n          \"source_range\": {\n            \"start\": 1,\n            \"length\": 4,\n            \"lines\": [\n              {\n                \"mode\": 1,\n                \"number\": 1,\n                \"content\": \"some\"\n              },\n              {\n                \"mode\": 1,\n                \"number\": 2,\n                \"content\": \"lines\"\n              },\n              {\n                \"mode\": 3,\n                \"number\": 3,\n                \"content\": \"in\"\n              },\n              {\n                \"mode\": 1,\n                \"number\": 4,\n                \"content\": \"file1\"\n              }\n            ]\n          },\n          \"target_range\": {\n            \"start\": 1,\n            \"length\": 4,\n            \"lines\": [\n              {\n                \"mode\": 2,\n                \"number\": 1,\n                \"content\": \"add a line\"\n              },\n              {\n                \"mode\": 1,\n                \"number\": 2,\n                \"content\": \"some\"\n              },\n              {\n                \"mode\": 1,\n                \"number\": 3,\n                \"content\": \"lines\"\n              },\n              {\n                \"mode\": 1,\n                \"number\": 4,\n                \"content\": \"file1\"\n              }\n            ]\n          }\n        }\n      ]\n    }\n  ]\n}\n*/\n```\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/lower-coder/go-git-diff)](https://goreportcard.com/report/github.com/lower-coder/go-git-diff)\n[![license](https://img.shields.io/github/license/lower-coder/go-git-diff)](https://img.shields.io/github/license/lower-coder/go-git-diff)\n[![go-version](https://img.shields.io/github/go-mod/go-version/lower-coder/go-git-diff)](https://img.shields.io/github/go-mod/go-version/lower-coder/go-git-diff)\n[![contributors](https://img.shields.io/github/contributors/lower-coder/go-git-diff)](https://img.shields.io/github/contributors/lower-coder/go-git-diff)\n[![stars](https://img.shields.io/github/stars/lower-coder/go-git-diff)](https://img.shields.io/github/stars/lower-coder/go-git-diff)\n[![lines](https://img.shields.io/tokei/lines/github/lower-coder/go-git-diff)](https://img.shields.io/tokei/lines/github/lower-coder/go-git-diff)\n[![downloads](https://img.shields.io/github/downloads/lower-coder/go-git-diff/total)](https://img.shields.io/github/downloads/lower-coder/go-git-diff/total)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzihuan-yan%2Fgo-git-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzihuan-yan%2Fgo-git-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzihuan-yan%2Fgo-git-diff/lists"}