Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace interface{} with any #568

Merged
merged 4 commits into from
Feb 11, 2025

Conversation

benhoyt
Copy link
Contributor

@benhoyt benhoyt commented Feb 5, 2025

any is (as of Go 1.18) a builtin alias for interface{}, equivalent in every respect. It was introduced in Go 1.18+, and our go.mod says we're on 1.22. A similar thing was done to the Go project and stdlib a while back, see for example https://pkg.go.dev/encoding/json#Marshal

Commands used to generate this PR (based on the same thing done to the Go project):

$ sed -i 's,interface{},any,g' **/*.go
$ sed -i 's,interface{},any,g' **/**/*.go
$ sed -i 's,interface{},any,g' **/**/**/*.go
# I'm not actually sure why the last two were needed here and not for Go,
# but the first one only did the client package

go fmt ./...

This also adds a GitHub Action (part of the format checks) that runs grep to ensure we don't have any remaining interface{}, for example from in-flight PRs. See failing example run.

It was introduced in Go 1.18+, and our go.mod says we're on 1.22.
@benhoyt benhoyt requested a review from flotter February 5, 2025 02:51
@benhoyt
Copy link
Contributor Author

benhoyt commented Feb 5, 2025

@flotter @pedronis What do you think about doing this to snapd and other codebases derived from Pebble, seeing we like to keep in sync?

@flotter
Copy link
Contributor

flotter commented Feb 5, 2025

@benhoyt I do not have a strong opinion other than the change does not bother me (it makes sense to follow what others are doing for me), and if you do it, we will follow.

@benhoyt benhoyt merged commit 1b90005 into canonical:master Feb 11, 2025
18 checks passed
@benhoyt benhoyt deleted the empty-interface-to-any branch February 11, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants