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