Replying to this post.

I decided to generate the gif in golang too. Palette quantisation was fun to learn about; how you take a 32 bit colour image and decide which colours you should use when downsampling into 256 colours.

I used the "Median Cut" method (github.com/…/quantize)