We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Nilaway fail to get the correct answer when using errgroup(case1). But it works fine in normal case(case2).
package main import ( "context" "fmt" "golang.org/x/sync/errgroup" ) func getData(s string) (*string, error) { if s == "" { return nil, fmt.Errorf("empty data") } return &s, nil } // Not OK func case1() { g, _ := errgroup.WithContext(context.Background()) var s *string g.Go(func() error { var err error s, err = getData("hello") if err != nil { return err } return nil }) if err := g.Wait(); err != nil { return } fmt.Println(*s) } // OK func case2() { var s *string var err error s, err = getData("hello") if err != nil { return } fmt.Println(*s) } func main() { case1() case2() } // error: Potential nil panic detected. Observed nil flow from source to dereference point: // - hello_world/main.go:30:15: unassigned variable `s` dereferenced
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Nilaway fail to get the correct answer when using errgroup(case1). But it works fine in normal case(case2).
The text was updated successfully, but these errors were encountered: