3 ms·
Packages extensively using reflect + interfaces together can be a bit of a pain to work through. :/
by justinclift 7y ago
Packages extensively using reflect + interfaces together can be a bit of a pain to work through. :/
- sagichmal 7y agoAbsolutely. But those are clear code smells. Any org with competent code review would flag them and kill them before they proliferated.
- jeremyjh 7y agoWould you consider k8s to be developed by a competent org? They have 2324 func declarations that take or return an interface{} on master right now.
- sagichmal 7y agoKubernetes, like Docker, is notoriously bad Go. The authors essentially transliterated Java.
- inlined 7y agoThis. It was really hard to enforce supplementary style across my team to match common conservatism in popular codebases (e.g. only return a single value or a value and bool/error. Don’t expose channels in APIs) when K8s so blatantly fails them.
- justinclift 7y agoHave you seen the internals of the Go http library? :)
- inlined 7y agoHave you seen the internals of the rand library? HTTP uses interfaces cleverly to detect optional interfaces. Today I found out that rand.Rand does a type check on every core method to see if it’s source is the hidden type for global methods.