A Go HTTP server can accept browser requests directly and return responses without a separate web server in front of the application. The standard library's net/http package supplies the listener and request handlers. Go handles connections concurrently using goroutines, which the runtime manages across application threads. section 1.3.4 section 1.5
Serve a response on localhost
Initialize a module with `go mod init hellogo`, then save this as `main.go`: package main import ( "fmt" "net/http" ) func hello(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, my name is Inigo Montoya") } func main() { http.HandleFunc("/", hello) http.ListenAndServe("localhost:4000", nil) } Run `go run main.go` and open `http://localhost:4000/` in a browser. `HandleFunc` associates the `/` path with a handler; `ListenAndServe` starts listening. The handler receives a request and writes its response through `http.ResponseWriter`. This minimal example does not check the error returned by `ListenAndServe`. section 1.5
The listener is only a starting point. Routing matches paths to the right handlers; middleware can collect common tasks instead of duplicating them in each handler. A command-line server also needs configuration and deliberate startup and shutdown. For larger applications, plan how these building blocks meet real traffic and operational requirements before adding a framework: a framework may provide useful features, but can also add unneeded functionality, latency, or security risks. section 2.0 section 8.0
Handlers can grow beyond a greeting. They can accept form data and uploads, serve files or custom error pages, and stream incoming data. An API server can also be one component of a larger service: for example, it can accept a media upload, store the file, and queue a transcoding job. section 10.3 section 12.2










