TutorialPedia.org
Toggle Menu
Home
Online Go Compiler
Tutorials
JavaScript Tutorials
Golang Tutorials
Linux Command Line Tutorials
Blog
All Posts
Go Web Development
Check your knowledge of building web servers and REST APIs using Go’s net/http package.
1. Which package provides core HTTP server and client functionality in Go?
net/http
http/server
go/http
web/net
2. What is the default HTTP multiplexer (router) in Go's net/http package?
DefaultRouter
ServeMux
DefaultServeMux
HTTPMux
3. Which function is used to start an HTTP server on a specified address in Go?
http.StartServer
http.ListenAndServe
http.RunServer
http.ServeOn
4. What is the signature of the function passed to http.HandleFunc?
func(w http.Response, r *http.Request)
func(w http.ResponseWriter, r *http.Request)
func(r *http.Request, w http.ResponseWriter)
func(writer http.Writer, req *Request)
5. Which HTTP status code is returned by http.StatusNotFound?
200
400
404
500
6. What does the http.Request struct represent in Go?
A client response
An incoming client request
A server configuration
A middleware chain
7. Which method is used to extract query parameters from an http.Request?
r.QueryParams()
r.GetQuery()
r.URL.Query()
r.Params.Get()
8. What is the return type of the http.Get function?
(*http.Response, error)
http.Response
([]byte, error)
string
9. Which function is used to parse form data from a POST request in http.Request?
r.Parse()
r.ParseForm()
r.FormParse()
r.GetForm()
10. What is the default port when calling http.ListenAndServe with address ":8080"?
80
443
8080
3000
11. Which of the following are valid middleware patterns in Go web development?
Logging incoming requests
Authentication/Authorization checks
CORS header management
Database connection pooling
12. Which of these functions/approaches can send JSON responses in Go?
json.NewEncoder(w).Encode(data)
w.Write(json.Marshal(data)) after setting Content-Type to application/json
http.JSON(w, http.StatusOK, data)
w.JSON(data)
13. Which of the following are popular third-party routers for Go web development (beyond the default ServeMux)?
gorilla/mux
chi
echo
net/httprouter
14. Which methods are part of the http.Handler interface?
ServeHTTP(w http.ResponseWriter, r *http.Request)
Handle(w http.ResponseWriter, r *http.Request)
Do(r *http.Request) (*http.Response, error)
None of the above
15. The http.ResponseWriter interface includes a WriteHeader method to set the HTTP status code.
True
False
16. Goroutines cannot be used within HTTP handlers to process requests concurrently.
True
False
17. The context package is used to manage request-scoped values, cancellation, and timeouts in Go web applications.
True
False
18. What is the full import path of the standard library package used for server-side HTML templating in Go?
19. Name the method chain used to set a response header (e.g., Content-Type) in http.ResponseWriter. (format: Method1().Method2)
20. What is the default Content-Type header value when using http.ResponseWriter.Write with a plain string?
Reset
Answered 0 of 0 — 0 correct