更新了自己的 doa 库:
这个迷你库的目的是当检测到 error 时立即 panic 掉程序.
核心代码其实就一行函数定义:
// Try will give you the embedded value if there is no error returns. If instead error then it will panic.
func Try[T any](a T, err error) T {
if err != nil {
panic(err)
}
return a
}