Hacker News new | past | comments | ask | show | jobs | submit login

Feel a great sense of relief reading this. This fixes the single biggest wart in Go.



No, 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?


Next they can fix nil checks on interfaces.


Unfortunately, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: