By default, Go's http.Get() has no timeout.
If the server hangs, your request can wait forever.
Set one yourself:
client := &http.Client{
Timeout: 5 * time.Second,
}
resp, err := client.Get(url)
Now a slow server costs you 5 seconds, not your whole service.
#golang
You do not need to nil check a Go map before reading it.
var m map[string]string
m["env"] -> ""
len(m) -> 0
v, ok := m["x"] -> "", false
for range m -> zero iterations
All fine on a nil map.
Only writing panics:
m["env"] = "prod"
5 allocations, or 28. Same JSON.
struct: 5 allocs, 304 B
map[string]any: 28 allocs, 920 B
A struct lets the decoder write straight into known fields.
A map boxes every value it meets, one allocation at a time.
Allocations are what your GC feels.
Golang's rise in developer adoption, 2017–2026
Simple syntax. Built-in concurrency. Fast compilation. Golang has steadily earned its place in modern backend engineering, from microservices to cloud infrastructure.
Source: survey.stackoverflow.co#Golang#Backend#Developers