Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error return value of XXXX is not checked (errcheck) #436

Open
wwcchh0123 opened this issue Nov 8, 2024 · 0 comments
Open

Error return value of XXXX is not checked (errcheck) #436

wwcchh0123 opened this issue Nov 8, 2024 · 0 comments

Comments

@wwcchh0123
Copy link
Contributor

wwcchh0123 commented Nov 8, 2024

lint 解释

  • 该 lint 的 出现是由于相关“XXXX”函数返回的错误没有有进行校验,尤其是错误值(error 类型)是否被正确处理。未检查的错误可能导致程序在运行时出现未捕获的异常,进而导致不可预见的行为或崩溃。

错误用法

func testfunc(){
    return err
}
func main() {
    // 未进行错误校验
    testfunc()
    // .....
    // ......
}

正确用法

func main() {
    // 进行错误校验
    err := testfunc()
    if err != nil {
        // 处理错误
        return
    }
    // .....
    // ......
}
@wwcchh0123 wwcchh0123 changed the title Error return value of XXXXXX is not checked (errcheck) Error return value of “XXXX” is not checked (errcheck) Nov 8, 2024
@wwcchh0123 wwcchh0123 changed the title Error return value of “XXXX” is not checked (errcheck) Error return value of XXXX is not checked (errcheck) Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant