[Go] if - scoped variable

// Defined a err variable err and assige the return value of someFunction()
// err only available in if {} block, not outside
if err := someFunction(); err != nil {
    fmt.Println(err)
}

 

posted @ 2022-09-04 16:02  Zhentiw  阅读(18)  评论(0编辑  收藏  举报