Skip to content

Instantly share code, notes, and snippets.

@jfamousket
Created October 14, 2021 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfamousket/2777c8fb728c2536780ac45b8d8c7291 to your computer and use it in GitHub Desktop.
Save jfamousket/2777c8fb728c2536780ac45b8d8c7291 to your computer and use it in GitHub Desktop.
Golang Tips

serve JSON http response

rw.Header().Set("Content-Type", "application/json")

json.NewEncoder(rw).Encode(struct{ Status int json:"status" }{ Status: http.StatusOk })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment