Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by benhoyt on Saturday July 29, 2023 @09:46PM
(#36926904)
I'm guessing you're being sarcastic. If so, it's not really a fair criticism. Go has properly-typed return values (not just parsing text from stdout) and any type can implement the error interface, allowing for error types with any custom, properly-typed attributes. You use Go's type assertion or errors.Is / errors.As to handle the latter.
[ Parent
| on HN ]
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by coryrc on Saturday July 29, 2023 @10:39PM
(#36927273)
Maybe it's my job, but I don't see a lot of Go code treating errors as anything but strings. Errors I get from Go programs are similarly vague and redundant and lacking context. ("error from RPC: failure making from call: couldn't complete operation: 7 is not a valid flag" ah thanks, so much better than stack trace)
Also it's the weekend and I'm just bitching.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by benhoyt on Saturday July 29, 2023 @10:52PM
(#36927346)
I think that's a fair critique. You have to really put thought into good error messages and error handling. When you do, they're nicer and more informative than an ugly stack trace. But a poor error message chain like the one you've shown is significantly less helpful than a stack trace.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by stouset on Saturday July 29, 2023 @11:10PM
(#36927432)
Yes, but don’t you value the fact that this error message was painstakingly crafted by hand under the care of skilled golang artisans instead of being mass-produced by an automated exception handler?
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by ttymck on Sunday July 30, 2023 @12:13AM
(#36927741)
Yeah because that's the error interface? It's literally a method that returns string.
Unfortunately, I guess after the fact they decided pattern matching was useful, so they did it via reflection (errors.As). But they don't warn you that errors.Is might return false for a true errors.As, it is certainly a mess, but the pedagogy could be improved.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by zaphirplane on Sunday July 30, 2023 @12:30AM
(#36927813)
> Also it's the weekend and I'm just bitching
You prefer and in a better mood during the working week ? Interesting
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by Brian_K_White on Monday July 31, 2023 @11:29AM
(#36944130)
You jump to a critical interpretation instead of allowing for instance "It's the weekend when I'm off the clock and don't police myself so much"? Interrsting.
Re:Show HN: Gogit – Just enough Git (in Go) to push itself t...
by maccard on Sunday July 30, 2023 @04:48AM
(#36929213)
I'd like to join the weekend bitching. I do think go's errors are often shitty. Stacktraces are easy to get with [0] and you can always do fmt.Errorf("%s", string(debug.Stack()) to get them in an error. I've not profiled them in go, but in native code they're horribly inefficient to gather so you don't want to be using them unless you really want to I'd bet
That said, other applications have exceptions and people still manage to write functions that return a Boolean to indicate success, and log an equally unhelpful message rather than returning anything I can work with. Maybe we need new programmers.