How I moved my website from Django (Python) to Go (English)

2015-01-20

This blog has run on many languages, starting by the one I know the most: PHP (with Symfony framework), trying to learn new things by migrating to Python (with Django framework) and is now running under Go.

The (very-micro-)framework I've wrote to learn

So this blog is now running under Golang and particularly under Gofast, a micro-framework I've wrote in order to learn the language. Its code is open-sourced on my Github account so you can take a look if you are interested in. This is really simple code that allows to run a simple web application (as this website).

Golang comes with some really powerful packages that helps me a lot in this migration.

You can see that here, we bootstrap the micro-framework and retrieve the context structure.

From this structure, you can retrieve the router (as done in the example below), the request, the response and the templating.

Rendering templates with Pongo2 library

Gofast micro-framework templating is using Pongo2 library as it allows to use quite-same templates as Django ones.
Almost all functions are working (excepts date ones as it is really different in Go) so I do not have to rewrite all my templates for the migration.

Imagine you have a homepage.html template, this library allows you to render a Jinja template (Django templating syntax) by simply using the following code: