Skip to content

Commit

Permalink
apidiff: ignore internal packages
Browse files Browse the repository at this point in the history
A feature is added to apidiff that allows users to ignore internal package comparisons

Fixes golang/go#52864.
  • Loading branch information
gh73962 committed May 16, 2022
1 parent 3b7c810 commit 367ebca
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cmd/apidiff/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
var (
exportDataOutfile = flag.String("w", "", "file for export data")
incompatibleOnly = flag.Bool("incompatible", false, "display only incompatible changes")
allowInternal = flag.Bool("allow-internal", false, "allow apidiff to compare internal packages")
)

func main() {
Expand Down Expand Up @@ -45,10 +46,6 @@ func main() {
os.Exit(2)
}
pkg := mustLoadPackage(flag.Arg(0))
// if the package is an internal package, ignore it
if isInternalPackage(pkg.PkgPath) {
die("ignore internal package:%s", pkg.PkgPath)
}
if err := writeExportData(pkg, *exportDataOutfile); err != nil {
die("writing export data: %v", err)
}
Expand All @@ -59,9 +56,11 @@ func main() {
}
oldpkg := mustLoadOrRead(flag.Arg(0))
newpkg := mustLoadOrRead(flag.Arg(1))
// if the package is an internal package, ignore it
if isInternalPackage(oldpkg.Path()) || isInternalPackage(newpkg.Path()) {
return
if !*allowInternal {
if isInternalPackage(oldpkg.Path()) && isInternalPackage(newpkg.Path()) {
fmt.Fprintf(os.Stderr, "Ignoring internal package\n")
os.Exit(0)
}
}
report := apidiff.Changes(oldpkg, newpkg)
var err error
Expand Down

0 comments on commit 367ebca

Please sign in to comment.