Re-vendor the shared files from sneak/prompts at dd4027b (closes #52)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Takes .golangci.yml, .dockerignore, .gitignore, .editorconfig, the workflow and REPO_POLICIES.md from sneak/prompts dd4027b, keeping this repository's own entries after the shared content. Lint (golangci-lint v2.14.0) and test become Dockerfile phases that script/lint and script/test build alone and uncached; the image build depends on both, and script/cibuild bootstraps, runs script/check, then builds the image. The agent guidance file moves to AGENTS.md. The Go code is fixed for what the new configuration finds; reads that iterate rows now also report an iteration error. Model: opus-5-5
This commit is contained in:
@@ -19,29 +19,21 @@ func logSlowQuery(logger *logger.Logger, query string, start time.Time) {
|
||||
}
|
||||
|
||||
// queryRow wraps QueryRow with slow query logging
|
||||
// nolint:unused // kept for consistency with other query wrappers
|
||||
func (d *Database) queryRow(query string, args ...interface{}) *sql.Row {
|
||||
//
|
||||
//nolint:unused // kept for consistency with other query wrappers
|
||||
func (d *Database) queryRow(query string, args ...any) *sql.Row {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(d.logger, query, start)
|
||||
|
||||
return d.db.QueryRow(query, args...)
|
||||
}
|
||||
|
||||
// query wraps Query with slow query logging
|
||||
// nolint:unused // kept for future use to ensure all queries go through slow query logging
|
||||
func (d *Database) query(query string, args ...interface{}) (*sql.Rows, error) {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(d.logger, query, start)
|
||||
|
||||
return d.db.Query(query, args...)
|
||||
return d.db.QueryRowContext(context.Background(), query, args...)
|
||||
}
|
||||
|
||||
// exec wraps Exec with slow query logging
|
||||
func (d *Database) exec(query string, args ...interface{}) error {
|
||||
func (d *Database) exec(query string, args ...any) error {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(d.logger, query, start)
|
||||
|
||||
_, err := d.db.Exec(query, args...)
|
||||
_, err := d.db.ExecContext(context.Background(), query, args...)
|
||||
|
||||
return err
|
||||
}
|
||||
@@ -49,35 +41,22 @@ func (d *Database) exec(query string, args ...interface{}) error {
|
||||
// loggingTx wraps sql.Tx to log slow queries
|
||||
type loggingTx struct {
|
||||
*sql.Tx
|
||||
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
// QueryRow wraps sql.Tx.QueryRow to log slow queries
|
||||
func (tx *loggingTx) QueryRow(query string, args ...interface{}) *sql.Row {
|
||||
func (tx *loggingTx) QueryRow(query string, args ...any) *sql.Row {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
return tx.Tx.QueryRow(query, args...)
|
||||
}
|
||||
|
||||
// Query wraps sql.Tx.Query to log slow queries
|
||||
func (tx *loggingTx) Query(query string, args ...interface{}) (*sql.Rows, error) {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
return tx.Tx.Query(query, args...)
|
||||
}
|
||||
|
||||
// QueryContext wraps sql.Tx.QueryContext to log slow queries
|
||||
func (tx *loggingTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
return tx.Tx.QueryContext(ctx, query, args...)
|
||||
return tx.Tx.QueryRowContext(context.Background(), query, args...)
|
||||
}
|
||||
|
||||
// QueryRowContext wraps sql.Tx.QueryRowContext to log slow queries
|
||||
func (tx *loggingTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row {
|
||||
func (tx *loggingTx) QueryRowContext(
|
||||
ctx context.Context, query string, args ...any,
|
||||
) *sql.Row {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
@@ -85,15 +64,17 @@ func (tx *loggingTx) QueryRowContext(ctx context.Context, query string, args ...
|
||||
}
|
||||
|
||||
// Exec wraps sql.Tx.Exec to log slow queries
|
||||
func (tx *loggingTx) Exec(query string, args ...interface{}) (sql.Result, error) {
|
||||
func (tx *loggingTx) Exec(query string, args ...any) (sql.Result, error) {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
return tx.Tx.Exec(query, args...)
|
||||
return tx.Tx.ExecContext(context.Background(), query, args...)
|
||||
}
|
||||
|
||||
// ExecContext wraps sql.Tx.ExecContext to log slow queries
|
||||
func (tx *loggingTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (tx *loggingTx) ExecContext(
|
||||
ctx context.Context, query string, args ...any,
|
||||
) (sql.Result, error) {
|
||||
start := time.Now()
|
||||
defer logSlowQuery(tx.logger, query, start)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user