goplay: Embed Go Playground on your Website

This post is introducing a way to run Go snippets on websites. Which leveraged the official Go Playground service at https://go.dev/play/. Demo Let’s take a quick look at the two demos below. You can click the Run button to see the output of the corresponding program. Click Try it yourself or Share button to open the code in the official Go Playground to further edit/test the code on your hand....

May 11, 2022

Decode HTTP Query Params into a Struct in Go

Many people use net/http package directly in Go to deal with HTTP requests, including reading URL parameters, HTTP headers, and the request body. It’s straightforward and efficient, though. We can still get bored writing so much tedious code for just reading and parsing the URL params. Especially when we were maintaining a service with hundres of APIs. Let’s see a piece of code for dealing with HTTP requests by using net/http package:...

May 17, 2021