formatovany kod pomocou gofmt

This commit is contained in:
2026-01-22 13:09:22 +01:00
parent 6df8e53b53
commit 43ce34219c

View File

@ -34,13 +34,13 @@ type QueryRequest struct {
// QueryResult represents a single historical query execution
type QueryResult struct {
ID string `json:"id"`
Query string `json:"query"`
Timestamp int64 `json:"timestamp"`
Error string `json:"error,omitempty"`
Columns []string `json:"columns,omitempty"`
Rows [][]interface{} `json:"rows,omitempty"`
RowsAffected int64 `json:"rowsAffected,omitempty"`
ID string `json:"id"`
Query string `json:"query"`
Timestamp int64 `json:"timestamp"`
Error string `json:"error,omitempty"`
Columns []string `json:"columns,omitempty"`
Rows [][]interface{} `json:"rows,omitempty"`
RowsAffected int64 `json:"rowsAffected,omitempty"`
}
var db *sql.DB
@ -141,10 +141,10 @@ func handleQuery(w http.ResponseWriter, r *http.Request) {
Timestamp: time.Now().UnixNano(),
}
// Generate new ID if it's a new query
if result.ID == "" {
result.ID = strconv.FormatInt(result.Timestamp, 10)
}
// Generate new ID if it's a new query
if result.ID == "" {
result.ID = strconv.FormatInt(result.Timestamp, 10)
}
if isSelect {
// It's a query that returns rows
@ -157,18 +157,18 @@ func handleQuery(w http.ResponseWriter, r *http.Request) {
result.Columns = cols
for rows.Next() {
// Create a slice of interface{}'s to represent a row
columns := make([]interface{}, len(cols))
columnPointers := make([]interface{}, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
// Create a slice of interface{}'s to represent a row
columns := make([]interface{}, len(cols))
columnPointers := make([]interface{}, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
// Scan the result into the column pointers...
if err := rows.Scan(columnPointers...); err != nil {
result.Error = err.Error()
break
}
// Scan the result into the column pointers...
if err := rows.Scan(columnPointers...); err != nil {
result.Error = err.Error()
break
}
// Convert byte slices to strings for better JSON representation
for i, col := range columns {
@ -177,7 +177,7 @@ func handleQuery(w http.ResponseWriter, r *http.Request) {
}
}
result.Rows = append(result.Rows, columns)
result.Rows = append(result.Rows, columns)
}
if err := rows.Err(); err != nil {
result.Error = err.Error()