package fts5 import ( "database/sql" "fmt" "strings" ) type preparer interface { Prepare(string) (*sql.Stmt, error) } func prepareInsertStmt( db preparer, columnNames []string, ) (*sql.Stmt, error) { insertQuery := fmt.Sprintf(`INSERT INTO search(rowid,%s) VALUES (?%s)`, strings.Join(columnNames, ","), strings.Repeat(",?", len(columnNames))) return db.Prepare(insertQuery) } func execInsertStmt( stmt *sql.Stmt, colNames []string, id int64, data map[string]string, ) error { values := make([]any, len(colNames)+1) values[0] = id for i, col := range colNames { values[i+1] = data[col] } _, err := stmt.Exec(values...) return err }