|
|
|
|
|
by maerF0x0
3234 days ago
|
|
IMO the language made a mistake by allowing nil to satisfy any interface . When I write a function like func DoStuf(i ILoveGoer) {
i.LoveGo() // Panic on nil
}
its hard to reason about because it doesnt look like you have a pointer, looks like you definitely have a value. IMO a nil should not be allowed for an interface. So the only way to create an interface var is in conjunction with assignment. |
|
Now, if this (admittedly uncommon) use-case is worth it's downsides is a different question, but that's how it's set up now.