google / styleguide

Style guides for Google-originated open-source projects
https://google.github.io/styleguide/
Apache License 2.0
37.01k stars 13.28k forks source link

Go: update `interface{}` to `any` #770

Open mvndaai opened 1 year ago

mvndaai commented 1 year ago

After go.1.18 you can use any and interface{} are interchangeably.

I would love the change so when I do a ctrl+F and look for styles around how interfaces should work I don't get false positives.

The style guide already prefers the use.

I would just want the examples here updated

adityakode commented 1 year ago

Hey! I am new here . Can you ps help and tell me what should be updated and with what?

mvndaai commented 1 year ago

Change https://github.com/google/styleguide/blob/gh-pages/go/decisions.md?plain=1#L2981

func IsNotNil(t *testing.T, name string, val interface{}) {

to

func IsNotNil(t *testing.T, name string, val any) {

Change these two

https://github.com/google/styleguide/blob/gh-pages/go/best-practices.md?plain=1#L1258 https://github.com/google/styleguide/blob/gh-pages/go/best-practices.md?plain=1#L1275

func Sprintf(format string, data ...interface{}) string

to

func Sprintf(format string, data ...any) string