apidiff: represent a Report as a list of Changes
Modify the Report representation to be a list of Change values,
instead of two string slices.
This will enable adding more information to each change, like source
location.
Change-Id: Ia7389d7bc552479ea5e06efd7fdefe004058e66f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172777
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
diff --git a/internal/apidiff/apidiff.go b/internal/apidiff/apidiff.go
index dc0f0e7..76669d8 100644
--- a/internal/apidiff/apidiff.go
+++ b/internal/apidiff/apidiff.go
@@ -24,10 +24,14 @@
func Changes(old, new *types.Package) Report {
d := newDiffer(old, new)
d.checkPackage()
- return Report{
- Incompatible: d.incompatibles.collect(),
- Compatible: d.compatibles.collect(),
+ r := Report{}
+ for _, m := range d.incompatibles.collect() {
+ r.Changes = append(r.Changes, Change{Message: m, Compatible: false})
}
+ for _, m := range d.compatibles.collect() {
+ r.Changes = append(r.Changes, Change{Message: m, Compatible: true})
+ }
+ return r
}
type differ struct {