Found some really nice things about Netlify today.

I learnt that you can write server-side functions in Go. I knew that JavaScript functions were supported but I had no idea that Go was a possibility. This excites me as Go is my favourite backend language.

From my testing it looks like the build will use a go.mod file for dependencies if one exists in the project root directory (i.e. the repository directory), so you can include third-party packages. Embeds also seem to work as well.

The functions are executed using AWS Lambda. You can use aws-lambda-go-api-proxy if you prefer to use http.Handler from the standard library:

func helloHandler(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusOK)
    w.Write([]byte("Hello world"))
}

func main() {
    adapter := httpadapter.New(http.HandlerFunc(helloHandler))
    lambda.Start(adapter.ProxyWithContext)
}

I also learnt that you can protect individual sites with a password, so if I ever want to deploy something for myself, I don’t have to roll my own authentication. This is a paid feature, but you know what, Netlify has been pretty good at hosting my other sites for free it’s probably worth signing up for a pro account.