styleguide icon indicating copy to clipboard operation
styleguide copied to clipboard

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

Open mvndaai opened this issue 1 year ago • 2 comments

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

  • https://google.github.io/styleguide/go/decisions#assertion-libraries
  • https://google.github.io/styleguide/go/best-practices#parameters-and-configuration

mvndaai avatar Apr 26 '23 22:04 mvndaai

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

adityakode avatar Apr 27 '23 14:04 adityakode

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

mvndaai avatar May 07 '23 05:05 mvndaai