Golang Portfolio

A couple of years ago I started experimenting with new programming languages. Up to that point I was mainly working with C++ and I wanted to try out more modern languages with simpler compilation processes ( anything other CMake, make or having to deal with linking static libraries in xcode or visual studio)

That’s when I ran into go and was really moved by the talk by Rob Pike - Simplicity is complicated

And decided to dive into the language and do a series of small projects with it. One of these projects is this static website/portfolio generated by GO.

The Repo is divided into a couple of parts:

Projects

  1. A project is defined by a json file pointing to a markdown or html file for the actual written content and a data folder for images, videos specific to that project.
  2. an input folder containing all the projects
  3. an json file defining what projects will be compiled into what category (projects, Experiments or Archive )

Build system

It’s in charge of collecting all projects from the data folder and creating their corresponding HTML page from a markdown or raw text.

It also generates the common components used in the website like header, index, experiments and archive page.

Server

A simple static server using golang standard libraries, it re-generates the HTML in every project; and it’s mainly used as a quick hot-reload development cycle

Program Flow

  1. The program reads the json file defining the projects and renders an HTML page, then copies the files (if changed, see bellow) inside data into a static output folder

File Caching

For every file inside data folder, the program runs a MD5 hash and saves that into a cache.json file, if on the next run the MD5 hash is the same one inside the cache file definition, it skips copying the file to the output build saving some time and resources.

example of cache:

"CacheMap": {
		"assets/data/akamai_sculpture/akamai_thumbnail.mp4": "16b756e8c67e3ea6c887d75a81a54bea",
		"assets/data/akamai_sculpture/data/1_map2.mp4": "76b759d9cb9294ffd006036a076349d2",
		"assets/data/akamai_sculpture/data/2_app_ff.mp4": "91d66577b72cb01128c1158e0ca7ba15",
		"assets/data/akamai_sculpture/data/3_lua_debug.mp4": "ff411ec2b7f620c72ab57ccbd2aa41d6",
		"assets/data/borea/borea_data/borea_pss.gif": "34a568a680d4e97c231c2dfdd8bee942",
		"assets/data/borea/borea_thumb.gif": "8a65e1843d231e604220f3f7928583b6",
		"assets/data/coca/coca-thumb.mp4": "8dc82a447410792324fb0e5bd50d7cbe",
... 
}

Good Parts:

I was really impressed of how much you can accomplish with such a simple language, for example GO only has array, slices and map for container like structures. Coming from c++ where you have map, unordered_map, list, set etc.. having just two options was strange at first but with time you only really need those data structures, if you need something more complex you can search a library.

With c++ I always trouble figuring it out if wrote software was using the correct abstraction, with GO you only have a couple of options and it’s really a refreshing feeling because you can focus on finshing the project.

The bad parts:

This project doesn’t really utilize GO’s main feature: concurrency. While there still many parts that that could be applied for example: generating the projects, rendering the HTML and copying the files.