golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.97k stars 17.53k forks source link

x/exp/cmd/apidiff: reports bogus changes between identical export data #67051

Open pohly opened 4 months ago

pohly commented 4 months ago

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/pohly/.cache/go-build'
GOENV='/home/pohly/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/nvme/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/nvme/gopath'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/nvme/gopath/go-1.22.0'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/nvme/gopath/go-1.22.0/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/nvme/gopath/src/k8s.io/kubernetes/go.mod'
GOWORK='/nvme/gopath/src/k8s.io/kubernetes/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3365691786=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I am running apidiff -w twice, then compare the exported data. Specific steps:

What did you see happen?

Ignoring internal package k8s.io/client-go/applyconfigurations/internal
Ignoring internal package k8s.io/client-go/tools/internal/events
Ignoring internal package k8s.io/client-go/applyconfigurations/internal
Ignoring internal package k8s.io/client-go/tools/internal/events
Incompatible changes:
- ./util/workqueue.BucketRateLimiter: changed from TypedBucketRateLimiter[any] to TypedBucketRateLimiter[T comparable]
- ./util/workqueue.DelayingQueueConfig: changed from TypedDelayingQueueConfig[any] to TypedDelayingQueueConfig[T comparable]
- ./util/workqueue.ItemExponentialFailureRateLimiter: changed from TypedItemExponentialFailureRateLimiter[any] to TypedItemExponentialFailureRateLimiter[T comparable]
- ./util/workqueue.ItemFastSlowRateLimiter: changed from TypedItemFastSlowRateLimiter[any] to TypedItemFastSlowRateLimiter[T comparable]
- ./util/workqueue.MaxOfRateLimiter: changed from TypedMaxOfRateLimiter[any] to TypedMaxOfRateLimiter[T comparable]
- ./util/workqueue.QueueConfig: changed from TypedQueueConfig[any] to TypedQueueConfig[T comparable]
- ./util/workqueue.RateLimitingQueueConfig: changed from TypedRateLimitingQueueConfig[any] to TypedRateLimitingQueueConfig[T comparable]
- ./util/workqueue.Type: changed from Typed[any] to Typed[t comparable]
- ./util/workqueue.WithMaxWaitRateLimiter: changed from TypedWithMaxWaitRateLimiter[any] to TypedWithMaxWaitRateLimiter[T comparable]

Note that e.g. type BucketRateLimiter = TypedBucketRateLimiter[any]. There is no TypedBucketRateLimiter[T comparable].

What did you expect to see?

No changes because the exported data is identical.

pohly commented 4 months ago

Side note: apidiff also treats https://github.com/kubernetes/kubernetes/commit/0c7370bb851c15825d30a516722139ccccca0cfc as an incompatible change:

Incompatible changes:
- ./util/workqueue.BucketRateLimiter: changed from BucketRateLimiter to TypedBucketRateLimiter[any]
- ./util/workqueue.DelayingQueueConfig: changed from DelayingQueueConfig to TypedDelayingQueueConfig[any]
- ./util/workqueue.ItemExponentialFailureRateLimiter: changed from ItemExponentialFailureRateLimiter to TypedItemExponentialFailureRateLimiter[any]
- ./util/workqueue.ItemFastSlowRateLimiter: changed from ItemFastSlowRateLimiter to TypedItemFastSlowRateLimiter[any]
- ./util/workqueue.MaxOfRateLimiter: changed from MaxOfRateLimiter to TypedMaxOfRateLimiter[any]
- ./util/workqueue.New: changed from func() *Type to func() *Typed[any]
- ./util/workqueue.NewDelayingQueueWithConfig: changed from func(DelayingQueueConfig) DelayingInterface to func(TypedDelayingQueueConfig[any]) DelayingInterface
- ./util/workqueue.NewMaxOfRateLimiter: changed from func(...RateLimiter) RateLimiter to func(...TypedRateLimiter[any]) RateLimiter
- ./util/workqueue.NewNamed: changed from func(string) *Type to func(string) *Typed[any]
- ./util/workqueue.NewRateLimitingQueueWithConfig: changed from func(RateLimiter, RateLimitingQueueConfig) RateLimitingInterface to func(RateLimiter, TypedRateLimitingQueueConfig[any]) RateLimitingInterface
- ./util/workqueue.NewWithConfig: changed from func(QueueConfig) *Type to func(TypedQueueConfig[any]) *Typed[any]
- ./util/workqueue.QueueConfig: changed from QueueConfig to TypedQueueConfig[any]
- ./util/workqueue.RateLimitingQueueConfig: changed from RateLimitingQueueConfig to TypedRateLimitingQueueConfig[any]
- ./util/workqueue.Type: changed from Type to Typed[any]
- ./util/workqueue.WithMaxWaitRateLimiter: changed from WithMaxWaitRateLimiter to TypedWithMaxWaitRateLimiter[any]

I think at least some of these are false positives. I can file a separate issue if desired.