We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代码:https://github.com/TencentBlueKing/bk-iam/blob/master/pkg/database/utils.go 使用场景:
// 生成统一的DB事务 tx, err := database.GenerateDefaultDBTx() defer database.RollBackWithLog(tx) // err如果不为nil,tx会为nil if err != nil { err = errorWrapf(err, "define tx fail") return }
// RollBackWithLog will rollback and log if error func RollBackWithLog(tx *sqlx.Tx) { // 这里加个tx nil判断 return最好 err := tx.Rollback() if err != sql.ErrTxDone && err != nil { logging.GetSQLLogger().Error(err) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
代码:https://github.com/TencentBlueKing/bk-iam/blob/master/pkg/database/utils.go
使用场景:
The text was updated successfully, but these errors were encountered: