4 ms·
I've worked on a million line Go code base and a dozen open source projects and many typical backend services, and interface{} is actually quite rare outside of
by NateDad 7y ago
I've worked on a million line Go code base and a dozen open source projects and many typical backend services, and interface{} is actually quite rare outside of something like json serialization or string printing - i.e. fmt.Printf(msg string, args ...interface{})
I almost never see code that application developers write using it, and usually if someone is writing that code, it's wrong, and I help them figure out how to avoid it.
Usually you can avoid it by using closures or interfaces.
- hombre_fatal 7y agoJust depends on the person. Some people like to copy and paste 50 times, some people use interface{}.
- NateDad 7y agoFunctions are a thing. Interfaces are a thing. I have literally never, in 6 years of full time go development, just copied and pasted code for the purpose of making it work with a different type. Nor has anyone I have worked with in that time (to my knowledge). I have seen two or three libraries written that use interface{}, but these are by far the exception.
- sacado2 7y agoJust depends on your application domain. I never copy/pasted code and could count the number of times I wrote `interface{}` on a single hand.
- gerbilly 7y ago> I've worked on a million line Go code base Oh so somebody has finally managed to implement fizz buzz in Go. Right on!