Recover from a Panic
How to catch a panic error when it’s thrown? That’s what this post hopes to answer. Go has a built in recover() function which allows you to pick up and run some code when a panic is thrown. This can be useful for regaining execution of your program, or allowing the panic to happen, but to clean up state (like files) before your program closes. If you are curious what the structure of a panic is, see it’s docs here.
Example Netlify Function in Go
Netlify, the hosting and web platform, allows you to create "functions" along with their CDN. These functions are hosted on AWS’ Lambda and can be accessible via a URL. So you can create static sites, with extra ability and dynamism (like we use on this site). We wanted to share a post giving an example how to write one of these functions in Go. The aim of the code (below) is to return the version of golang.