Hacker News new | ask | show | jobs
by topicseed 1304 days ago
Been writing Go for my own pet projects and some production side projects for two years. Often resorted to "small libraries" like Chi, or SQL query builders.

Since GitHub Copilot, I ditched SQL query builders as all the scanning and repetitive work is handled nearly immediately. I also ditched Chi and handle routing myself. Same for logging.

The issue is spending time doing things that took one line before with a framework (e.g., parsing URL path params). But it's actually satisfying.

1 comments

What does a typical handler look like in this scenario (url path params). I usually end up using Gorilla mux for this, but standard library for everything else.
I create a simple func for each handler to parse params. Most urls params are properly structured as /resources/{resourceID}/subresources/{subresourceID}.

So I can essentially create a map[string]string by splitting slashes and going 0 = key, 1 = value, 2 = key, 3 = value, etc.

If a handler uses a different structure like /resources/{resourceID}/{subresourceD}, I will have the func specifically handle that case.

Some ways may work better but this works for me and it's not magical, and I tend to touch that code once and never again so it's then out of the way, all in a file.