aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-toolsmith/astequal/diff.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-04 17:40:11 +0000
committerTaras Madan <tarasmadan@google.com>2024-03-04 18:34:55 +0000
commit5fc5366972c874b919f93165bb4ed4e2bcb7c350 (patch)
tree287c3361a0dee0c72af80d9a1a66714a06e98a62 /vendor/github.com/go-toolsmith/astequal/diff.go
parent1be5ce38a9059c356eb193a8c34d60d61c9fc31f (diff)
mod: bump github.com/golangci/golangci-lint from 1.55.2 to 1.56.2
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.55.2 to 1.56.2. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.55.2...v1.56.2) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/go-toolsmith/astequal/diff.go')
-rw-r--r--vendor/github.com/go-toolsmith/astequal/diff.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/go-toolsmith/astequal/diff.go b/vendor/github.com/go-toolsmith/astequal/diff.go
new file mode 100644
index 000000000..cd69b4525
--- /dev/null
+++ b/vendor/github.com/go-toolsmith/astequal/diff.go
@@ -0,0 +1,23 @@
+package astequal
+
+import (
+ "bytes"
+ "go/ast"
+ "go/format"
+ "go/token"
+
+ "github.com/google/go-cmp/cmp"
+)
+
+func Diff(x, y ast.Node) string {
+ var buf bytes.Buffer
+ format.Node(&buf, token.NewFileSet(), x)
+ s1 := buf.String()
+
+ buf.Reset()
+ format.Node(&buf, token.NewFileSet(), y)
+ s2 := buf.String()
+
+ // TODO(cristaloleg): replace with a more lightweight diff impl.
+ return cmp.Diff(s1, s2)
+}