3 ms·
I've seen goto used in golang stdlib for error handling https://github.com/golang/go/blob/master/src/strconv/atoi.go#L134 https://github.com/golang/go/blob/mas
by dominotw 11y ago
I've seen goto used in golang stdlib for error handling
https://github.com/golang/go/blob/master/src/strconv/atoi.go#L134 https://github.com/golang/go/blob/master/src/strconv/atoi.go...
- PeCaN 11y agoThat's a very common C idiom.
- rhinoceraptor 11y agoHere it is, used in OpenBSD's httpd: https://github.com/reyk/httpd/blob/master/httpd/httpd.c#L548 https://github.com/reyk/httpd/blob/master/httpd/httpd.c#L548
- AdmiralAsshat 11y agoMost reasonable programmers have understood "GOTO Considered Harmful" to be a recommendation, not a doctrine. Goto can be very useful when used carefully, most often for a "cleanup" block, as used in the example above. It's especially common in C where the memory needs to be freed before exiting.