google / exposure-notifications-server

Exposure Notification Reference Server | Covid-19 Exposure Notifications
https://www.google.com/covid19/exposurenotifications/
Apache License 2.0
2.39k stars 306 forks source link

Use generics for cache #1598

Closed sethvargo closed 2 years ago

sethvargo commented 2 years ago

I'm not actually convinced this is a good idea, but it's nice to avoid the type assertion.

Release Note

NONE
sethvargo commented 2 years ago

This does technically change the contract of the cacher. It used to be able to cache anything, even a mix of types. This forces an instance of the cacher to cache the same types.

sethvargo commented 2 years ago

Lol some of the linters don't understand the generics syntax:

Error: pkg/cache/cache.go:156:1: receiver-naming: receiver name c should be consistent with previous receiver name i for invalid-type (revive)