2015年1月22日星期四

Error-handling in Golang

     Error to catch in Golang is very different from other C like languages, just like other features of Golang, there's no try-catch or some else. See more from the Effective Go you can get primary feeling that there's only one level handling, just define a "defer" in each functions that would import "panic" or a potential crash.
    What programmer shouldn't forget is release necessary resource, like Channel what can block the program when you've forgotten put something into it. Here a  written sample to demonstrate when channel in recover phase not be told,  the "go run" can't be proceed by removing line 14
    Golang's error-handling works for each go-routine isolatedly, which means all go-routines don't interfere each other when some of them being "panic".

没有评论:

发表评论