Closed
Description
err := func()
if err != nil {
return errpkg.Wrap(err)
}
can change it to
~ = fun()
相当于如果~
的类型为error
,并且A()
的返回值为error
,并且~
不为nil
,这自动转换为 return errpkg.Wrap(err)
Equivalent to if the type of ~
is error
, and the return value of A()
is error
, and ~
is not nil
, this is automatically converted to return errpkg Wrap(err)
for example
fun A() error {
~ = fun()
}
// 相当于,Equivalent to
fun A() error {
err := func()
if err != nil {
return errpkg.Wrap(err)
}
}
fun A() (user error) {
~ = fun()
}
// 相当于,Equivalent to
fun A() error {
err := func()
if err != nil {
return nil, errpkg.Wrap(err)
}
}