{"id":15859412,"url":"https://github.com/nakabonne/fmtdiff","last_synced_at":"2025-10-03T22:59:32.449Z","repository":{"id":57504673,"uuid":"230572553","full_name":"nakabonne/fmtdiff","owner":"nakabonne","description":"A goimports client as well as a parser of its result","archived":false,"fork":false,"pushed_at":"2020-01-01T04:30:51.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T03:11:13.960Z","etag":null,"topics":["diff","go","go-library","gofmt","goimports","golang","parser"],"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/nakabonne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-28T07:03:24.000Z","updated_at":"2020-01-01T04:30:53.000Z","dependencies_parsed_at":"2022-08-30T03:41:16.195Z","dependency_job_id":null,"html_url":"https://github.com/nakabonne/fmtdiff","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakabonne%2Ffmtdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakabonne%2Ffmtdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakabonne%2Ffmtdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nakabonne%2Ffmtdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nakabonne","download_url":"https://codeload.github.com/nakabonne/fmtdiff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246705771,"owners_count":20820783,"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","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","go","go-library","gofmt","goimports","golang","parser"],"created_at":"2024-10-05T21:20:27.394Z","updated_at":"2025-10-03T22:59:27.401Z","avatar_url":"https://github.com/nakabonne.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fmtdiff\n\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/nakabonne/fmtdiff)\n[![codecov](https://codecov.io/gh/nakabonne/fmtdiff/branch/master/graph/badge.svg)](https://codecov.io/gh/nakabonne/fmtdiff)\n\nA `goimports` client as well as a parser that parses the diff between an original file and formatted one. You can use it as a wrapper for [golang.org/x/tools/imports](https://godoc.org/golang.org/x/tools/imports).  \n\ngoimports not only fixes imports, but also formats your code in the same style as gofmt, so `fmtdiff` means `importsdiff` substantially.\n\n## Installation\n\n```\ngo get github.com/nakabonne/fmtdiff\n```\n\n## Usage Example\n\n```go\npackage main\t\n\nimport \"github.com/nakabonne/fmtdiff\"\n\nfunc main() {\t\n\tfileDiff, _ := fmtdiff.Process(\"/path/to/foo.go\", \u0026fmtdiff.Options{\n\t\tLocalPrefixes:  []string{\"example.com/foo/bar\"},\n                IgnoreComments: true,\n                FormatOnly:     true,\n\t})\t\n}\n```\n\nCombined with [nakabonne/modpath](https://github.com/nakabonne/modpath), and then you can detect the local prefix from the `go.mod`.\n\n```go\nimport (\n\t\"github.com/nakabonne/modpath\"\n\t\n\t\"github.com/nakabonne/fmtdiff\"\n)\n\nfunc main() {\n\tprefix, _ := modpath.Run(\"/path/to/foo/bar\")\n\tfileDiff, _ := fmtdiff.Process(\"/path/to/foo.go\", \u0026fmtdiff.Options{\n\t\tLocalPrefixes:  []string{prefix},\n\t})\t\n}\n```\n\n## Thanks\n\nThanks to [sourcegraph/go-diff](https://github.com/sourcegraph/go-diff) for cool diff parser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnakabonne%2Ffmtdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnakabonne%2Ffmtdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnakabonne%2Ffmtdiff/lists"}