04. June 2015

Setting a custom response header in a Gin response

I’m using Gin Gonic on a project I’m working on at work these days. I was in a bit of a pickle where I had to specify a response body that I already had as a string, but I needed to put the correct content type header on the response (meaning I couldn’t use the built in .String or .JSON methods.

more

15. May 2015

An interesting example of using a closure for memoization

Long ago I wrote about the benefits of memoization. It’s a simple idea: a time vs. space trade off. Trade time in CPU for space in memory. A pretty classic example is the massive speed benefit you can get while calculating the Fibonacci sequence by saving values you have already found. (The naive recursive approach recalculates values an exponential number of times.) It’s a toy example but it definitely exhibits the power of the technique.

more