{"id":29881130,"url":"https://github.com/knsh14/astdiff","last_synced_at":"2025-07-31T10:33:36.852Z","repository":{"id":306819107,"uuid":"1013647284","full_name":"knsh14/astdiff","owner":"knsh14","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-04T08:35:01.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-27T21:18:11.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knsh14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T08:34:46.000Z","updated_at":"2025-07-04T08:35:04.000Z","dependencies_parsed_at":"2025-07-27T21:18:15.206Z","dependency_job_id":"22bf3f72-61cf-4c1a-a96a-ac192b4417a7","html_url":"https://github.com/knsh14/astdiff","commit_stats":null,"previous_names":["knsh14/astdiff"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/knsh14/astdiff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fastdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fastdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fastdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fastdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knsh14","download_url":"https://codeload.github.com/knsh14/astdiff/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knsh14%2Fastdiff/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268024672,"owners_count":24183149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-07-31T10:33:32.837Z","updated_at":"2025-07-31T10:33:36.843Z","avatar_url":"https://github.com/knsh14.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# astdiff\n\nA Go library and CLI tool for comparing Go source files based on their Abstract Syntax Trees (AST).\n\n## Features\n\n- Compare Go source files at the AST level\n- Detect additions, deletions, and modifications\n- Use as a library or command-line tool\n- Support for text and JSON output formats\n\n## Installation\n\n### As a CLI tool\n\n```bash\ngo install github.com/knsh14/astdiff/cmd/astdiff@latest\n```\n\n### As a library\n\n```bash\ngo get github.com/knsh14/astdiff\n```\n\n## Usage\n\n### CLI\n\n```bash\n# Compare two Go files (like standard diff command)\nastdiff file1.go file2.go\n\n# Show more context lines\nastdiff -u 5 old.go new.go\n\n# Show help\nastdiff -h\n```\n\n### Library\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/knsh14/astdiff\"\n)\n\nfunc main() {\n\t// Compare files\n\tdiff, err := astdiff.DiffFiles(\"old.go\", \"new.go\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Print human-readable output\n\tfmt.Println(diff.String())\n\n\t// Or get JSON output\n\tjson, err := diff.JSON()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(json)\n}\n```\n\nYou can also compare from readers or byte slices:\n\n```go\n// From readers\ndiff, err := astdiff.DiffReaders(\"old.go\", oldReader, \"new.go\", newReader)\n\n// From source code\noldSrc := []byte(`package main\nfunc main() {\n\tprintln(\"hello\")\n}`)\nnewSrc := []byte(`package main\nfunc main() {\n\tprintln(\"world\")\n}`)\ndiff, err := astdiff.DiffSource(\"old.go\", oldSrc, \"new.go\", newSrc)\n```\n\n## Example\n\nGiven these two files:\n\n**old.go:**\n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"Hello, World!\")\n\tx := 10\n\ty := 20\n\tresult := add(x, y)\n\tfmt.Printf(\"Result: %d\\n\", result)\n}\n\nfunc add(a, b int) int {\n\treturn a + b\n}\n```\n\n**new.go:**\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc main() {\n\tfmt.Println(\"Hello, Go!\")\n\tx := 10\n\ty := 30\n\tresult := multiply(x, y)\n\tfmt.Printf(\"Result: %d\\n\", result)\n\t\n\tname := strings.ToUpper(\"gopher\")\n\tfmt.Println(name)\n}\n\nfunc multiply(a, b int) int {\n\treturn a * b\n}\n```\n\nRunning `astdiff -old=old.go -new=new.go` will show:\n- Import of \"strings\" was added\n- Function body of main() was modified\n- Function add() was deleted\n- Function multiply() was added\n- Variable assignments changed\n\n## How it works\n\nastdiff parses both Go source files into Abstract Syntax Trees using Go's `go/ast` package, then recursively compares the tree nodes to identify structural differences. This provides more meaningful comparisons than text-based diff tools for understanding code changes.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknsh14%2Fastdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknsh14%2Fastdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknsh14%2Fastdiff/lists"}