Skip to content

chore(go): Rename interface{} to any for readability#517

Merged
candiduslynx merged 2 commits intomainfrom
chore/go19/use-any
Dec 20, 2022
Merged

chore(go): Rename interface{} to any for readability#517
candiduslynx merged 2 commits intomainfrom
chore/go19/use-any

Conversation

@candiduslynx
Copy link
Copy Markdown
Contributor

@candiduslynx candiduslynx commented Dec 18, 2022

Summary

any is an alias to interface{} introduced in Go 1.18. It's shorter and using it instead of interface{} improves readability a lot.

Marking this PR as a chore, as the functionality is left intact.


Use the following steps to ensure your PR is ready to be reviewed

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests 🧪
  • Ensure the status checks below are successful ✅

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 18, 2022

⏱️ Benchmark results

Comparing with cb7d2ad

  • DefaultConcurrency-2 resources/s: 11,964 ⬇️ 1.60% decrease vs. cb7d2ad
  • Glob-2 ns/op: 158.8 ⬆️ 8.88% increase vs. cb7d2ad
  • TablesWithChildrenDefaultConcurrency-2 resources/s: 29,454 ⬇️ 1.99% decrease vs. cb7d2ad
  • BufferedScanner-2 ns/op: 9.41 ⬇️ 7.76% decrease vs. cb7d2ad
  • LogReader-2 ns/op: 30.78 ⬆️ 0.78% increase vs. cb7d2ad

Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but maybe we should have a lint rule for it?

@candiduslynx
Copy link
Copy Markdown
Contributor Author

They are interchangeable. Also gen code (see ..._pb.go) sticks to interface{} for backward compatibility. I don't think we need a lint rule here.

@erezrokah
Copy link
Copy Markdown
Member

I don't think we need a lint rule here.

I mean if we chose one or the other (mostly for style I think) we should enforce it so our codebase is consistent.
It doesn't have to be in this PR, but maybe open an issue for it? Otherwise I can see someone re-adding interface{}

@candiduslynx
Copy link
Copy Markdown
Contributor Author

@erezrokah
I've just added the lint config t check for this.
if you have troubles on Mac with this, install diffutils via Brew

@candiduslynx candiduslynx force-pushed the chore/go19/use-any branch 2 times, most recently from f7e2a86 to be53e76 Compare December 19, 2022 12:03
@candiduslynx candiduslynx merged commit 8dcbe8d into main Dec 20, 2022
@candiduslynx candiduslynx deleted the chore/go19/use-any branch December 20, 2022 13:34
erezrokah pushed a commit to cloudquery/cloudquery that referenced this pull request Dec 20, 2022
daniel-garcia pushed a commit to infobloxopen/ibcq-source-k8s that referenced this pull request Feb 24, 2026
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.

4 participants