Skip to content

Latest commit

 

History

History
28 lines (26 loc) · 668 Bytes

README.md

File metadata and controls

28 lines (26 loc) · 668 Bytes

txcheck

txcheck is a program for checking that you call Begin whenever you call DML functions in go programs. Supports database/sql and github.com/gocraft/dbr.

Install

go get -u github.com/mcesar/txcheck

Use

For basic usage, just give the package path of interest as the first argument, for example:

txcheck github.com/mcesar/txcheck

Check

Given the following program, txcheck warns that function main calls Exec but does no call Begin (or BeginTx).

package main
import (
  "context"
  "database/sql"
)
var db *sql.DB
func main() {
  // tx, _ := db.Begin()
  db.Exec("INSERT INTO t(c) values('v');")
  // ...
}