Created
November 22, 2018 01:59
-
-
Save shumon84/ee409b7c9faca0c8e6bfbd0e0dc9a353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main(){ | |
db, _ := sql.Open("mysql", "user:password@tcp(host:port)/dbname") | |
tx, _ := db.Begin() | |
defer func() { | |
// panicが起きたらロールバック | |
if recover() != nil { | |
tx.Rollback() | |
} | |
}() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment