Go Replaces Interface{} with 'Any'
11–20 of 481 posts
Re: Go Replaces Interface{} with 'Any'
#12Re: Go Replaces Interface{} with 'Any'
#13This is great, as much as interface{} is not great, it's still part of the language and really verbose/non-descriptive. I'm guessing any was a forbidden word?
You mean a reserved keyword? No, 'any' is not a keyword, it's an identifier (a predeclared identifier). The usual shadowing rules apply.
Re: Go Replaces Interface{} with 'Any'
#14I like it, interface{} always felt unlike anything else in go other than structs.
func foo(x interface{String() string}) string {
return x.String()
}Re: Go Replaces Interface{} with 'Any'
#15Re: Go Replaces Interface{} with 'Any'
#16Re: Go Replaces Interface{} with 'Any'
#17This is great, as much as interface{} is not great, it's still part of the language and really verbose/non-descriptive. I'm guessing any was a forbidden word?
But having `any` as syntactic sugar for that concept is a good idea.
Re: Go Replaces Interface{} with 'Any'
#18So now that go has generics and modules, is there an up-to-date intro for writing cutting-edge Go code for people who are already pretty familiar with the older styles?
There is also a tutorial on generics: https://go.dev/doc/tutorial/generics
Re: Go Replaces Interface{} with 'Any'
#19It's a type alias, introduced for generics. By the way, Go 1.18 Beta 1 is released (with generics): https://groups.google.com/g/golang-announce/c/eAjK4Oezs_A
How is generics not a big enough change to warrant 2.0? Edit: I’m impressed generics aren’t a breaking change! I thought this changed Interface{} to Any as a breaking change
Re: Go Replaces Interface{} with 'Any'
#20So now that go has generics and modules, is there an up-to-date intro for writing cutting-edge Go code for people who are already pretty familiar with the older styles?
There is lots of tutorial-style documentation on modules: https://go.dev/doc/#developing-modules There is also a tutorial on generics: https://go.dev/doc/tutorial/generics