github.com/nakabonne/fmtdiff (go): Package fmtdiff implements a 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.
Keywords: diff|go|go-library|gofmt|goimports|golang|parser