Don't (always) Panic (from libraries)

posted on 2022.08.01 in golang panic error-handling
I recently had a bit of a discussion on Mastodon about panics and their purpose in Go and have heard some interesting “rules” around panics that essentially comes down to: Never panic in libraries unless you follow the informal agreement of prefixing your functions with Must. I think this is misguided rule and comes down to a misunderstanding of what painc() is in Go and confusing panic/recover with exceptions and error handing (usually coming from other languages that use exception).
Read More…

(Bad?) Experiments with Go generics

posted on 2020.06.21 in golang generics
The Go team just posted about The Next Step for Generics whiches shows the current progess for Generics in go which includes an updated draft which removed contracts completely and replaces them just with interfaces a long with a lot of different examples. In addition the go team created a translation tool that will take the experimental generic code and convert it to concreate types via monophorphization so that you can play with and experiment with the feature.
Read More…