The stdlib has something for this (as usual :P): 
``` go
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
```