Interview Q&A · questions with model answers
Go Web Frameworks Interview Questions
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked How do you test HTTP handlers in Go?
Use net/http/httptest: build a request with httptest.NewRequest, a recorder with httptest.NewRecorder, call router.ServeHTTP(rec, req), and assert on status, headers and body, usually in…
-
Most asked How should a Go service use database/sql correctly?
Open one *sql.DB (a concurrency-safe pool) at startup and share it, configure pool limits, always use placeholders, pass contexts to every query, close rows, check rows.Err(), and translate…
-
Most asked Do you need a web framework in Go? What does Go 1.22's ServeMux provide?
Often not. Since Go 1.22, http.ServeMux matches methods and path wildcards ("GET /books/{id}", read with r.PathValue), returns 405 for wrong methods, and prefers more specific patterns.
-
How does request validation work in Gin?
Bind the body into a struct with c.ShouldBindJSON(&in); binding tags like binding:"required,email,min=2" are checked by go-playground/validator during binding, and the error lists the failed fields.