Open takatoshiono opened 4 years ago
more simple sample code:
func f5(ctx context.Context, client *spanner.Client) error {
tx := client.ReadOnlyTransaction() // OK
defer tx.Close()
func() error {
_ = tx // use tx
return nil
}()
return nil
}
I think this issue has two bugs.
First bug is false positive of tx := client.ReadOnlyTransaction()
.
Second bug is false positive of _ = tx // use tx
.
Actually the below code zagane reports false positive in only case (2).
func() error {
func(tx *spanner.ReadOnlyTransaction) {}(tx) // (1) OK
_ = tx // (2) NG
return nil
}()
When I use errgroup, zagane reports
transaction must be closed
. I think that it's false positive detection.sample code: