Skip to content

Commit

Permalink
Merge pull request #44 from gcpug/add-test-for-issue32
Browse files Browse the repository at this point in the history
Add test for issue32
  • Loading branch information
tenntenn authored Sep 11, 2020
2 parents 739ffe3 + 83eeec5 commit 20de6de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions passes/unclosetx/testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"cloud.google.com/go/spanner"
"golang.org/x/sync/errgroup"
)

func f1(ctx context.Context, client *spanner.Client) {
Expand Down Expand Up @@ -54,3 +55,21 @@ func f5(ctx context.Context, client *spanner.Client) {
tx, _ := client.BatchReadOnlyTransaction(ctx, spanner.StrongRead()) // want "transaction must be closed"
_ = tx
}

// see https://github.com/gcpug/zagane/issues/32
func f6(ctx context.Context, client *spanner.Client) error {
tx := client.ReadOnlyTransaction() // OK
defer tx.Close()

var eg errgroup.Group

eg.Go(func() error {
_ = tx // use tx
return nil
})

if err := eg.Wait(); err != nil {
return err
}
return nil
}

0 comments on commit 20de6de

Please sign in to comment.