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 must be checked before other code run #232

Open
lx-world opened this issue Mar 29, 2023 · 0 comments
Open

Error must be checked before other code run #232

lx-world opened this issue Mar 29, 2023 · 0 comments

Comments

@lx-world
Copy link

package main

import (
	"errors"
	"fmt"
	"os"
)

type Stu struct {
	Age int
}

func AAA() (*Stu, error) {
	return nil, errors.New("error here")
}

func BBB() (v int, err error) {
	stu, err := AAA() //lint must return if err != nil
	stu.Age = 1
	return
}

func main() {
	res, err := BBB()
	fmt.Fprintln(os.Stdout, res, err)
}

this code can't check the err not return, so it panic.

I hope that this situation can be warned, or whether it is turned on or not controlled by parameters

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