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 about nested struct having Spanner's client #46

Open iwata opened 3 years ago

iwata commented 3 years ago

unclosetx cannot detect looks like this sample code.

func (h *Handler) fetchUser(ctx context.Context, userID string) (*database.User, error) {
    txn := h.repository.Client.ReadOnlyTransaction() // h.repository.Client is a Spanner client.

    user, err := database.FindUser(ctx, txn, userID)
    if err != nil {
        return nil, err
    }
    return user, nil
}