3 ms·
Feel a great sense of relief reading this. This fixes the single biggest wart in Go.
by wwarner 3y ago
Feel a great sense of relief reading this. This fixes the single biggest wart in Go.
- darren0 3y agoNext they can fix nil checks on interfaces.
- cyphar 3y agoUnfortunately, the distinction is sometimes (though rarely) useful and would be a far more disruptive change than this one. I think you would actually need a Go v2 to change it.
- maccard 3y agoNo, the biggest wart is error handling. foo, err := getFoo() if err != nil ... bar, err := getBar() fmt.Println(bar) Misses an error check on getBar. Scoping rules mean that if foo, err := getFoo(); err != nil Gets untenable with nesting fairly quickly. It also introduces invalid states - what does getFoo return if it returns an error too. Do we change the API to return a pointer and return nil, or do we have a partially constructed object that is in an invalid state?