package db import ( "sync" "github.com/jmoiron/sqlx" ) // *sqlx.NamedStmt pool var namedStmtPool = sync.Pool{ New: func() any { return &sqlx.NamedStmt{} }, } // NewNamedStmt alloc *sqlx.NamedStmt from pool func NewNamedStmt() *sqlx.NamedStmt { return namedStmtPool.Get().(*sqlx.NamedStmt) } // PutNamedStmt release *sqlx.NamedStmt to pool func PutNamedStmt(stmt *sqlx.NamedStmt) { namedStmtPool.Put(stmt) }