The standard Go Go library does not include a GIF encoder.
I think your best bet is to use cgo to interact with the C library, which encodes GIFs. giflib looks reasonably straight.
Alternatively, you can transfer the corresponding parts of giflib and send them to the standard library.
There is a historical reason that GIF encoding is not widespread - it was covered by patents for the LZW compression used. However, these patents have now expired, so there is no reason not to have a compressor in the standard library, except that GIFs are not as popular as before!
Nick Craig-Wood
source share