Golang Notes

This will likely be ported to a separate page at some point but I wanted to have a quick dump for things I’m learning.

Right now my focus is on learning how to do what I do every day in JavaScript: build web applications. In other words, I’m learning Go as a language by building things with it. Whenever I bump into something I don’t understand—or haven’t seen before—I’ve been looking stuff up on GoDoc which is a hell of a resource for understanding the standard libraries (i.e., pre-written libraries for performing common tasks like running an HTTP server, bundled with Go) as well as third-party libraries.

Right now, I’m just working on understanding basic HTTP requests using the net/http library; how to create a route, how to return a response, parsing and responding with JSON data, etc. This post was a ton of help in understanding the basic components of a non-trivial web server. It runs you through making an HTTP request to a third-party API, parsing that response, and then rendering the raw JSON in the browser.

What’s next on my list is understanding how to use some of the tools I’m more familiar with in JavaScript like React. So far the basic idea makes sense: just serve up the HTML files via the HTTP server and let JavaScript take over from there in respect to rendering components. This doesn’t fully answer the SSR question, but I have a hunch it’s going to be like anything else using React’s ReactDOMServer.renderToStaticMarkup() and passing in some data. This template has been helpful in understanding the basic pattern and indirectly introduced me to a live reload tool for Go called Gin.

Once I’ve got the basic UI/routing stuff down, I need to explore databases. I poked around to see if I could use GraphQL—you can, using this it seems—but I think I’ll just focus on using some simple adapters first and then look at that.