Skip to content

Commit

Permalink
apidiff: ignore internal pack
Browse files Browse the repository at this point in the history
The feature is added to apidiff which allows users to ignore internal package comparisons

Fixes golang/go#52864.
  • Loading branch information
gh73962 committed May 16, 2022
1 parent 3b7c810 commit eb63de3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 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 @@ -59,9 +60,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 %s\n", oldpkg.Path())
os.Exit(0)
}
}
report := apidiff.Changes(oldpkg, newpkg)
var err error
Expand Down

0 comments on commit eb63de3

Please sign in to comment.