gcpug / zagane

zagane is a static analysis tool which can find bugs in spanner's code
MIT License
89 stars 15 forks source link

unclosetx: not detect when a function called with a ReadOnlyTransaction argument #49

Open uechoco opened 2 years ago

uechoco commented 2 years ago

unclosetx cannot detect looks like this sample code.

func f7(ctx context.Context, client *spanner.Client) error {
    ro := client.ReadOnlyTransaction()
    err := Find01(ctx, ro)
    return err
}

func Find01(ctx context.Context, ro *spanner.ReadOnlyTransaction) error {
    row, err := ro.ReadRow(ctx, "DummyTable", spanner.Key{1}, []string{"Id"})
    log.Printf("row: %s", row)
    return err
}