Richard Bucker

envtmpl instead of safekeeper

Posted at — Apr 4, 2015

Recently I wrote about safekeeper and I complained about the use of a 3rd party package when it was not necessary. I also noticed that his code was overly stringified. (a) you had to specify which environment variable to process in the template. (b) the code had to prefix the variable names with ENV_ (c) I mentioned kingpinOne thing that caught my attention immediately; why not use golang’s templates? And then the second thing… doesn’t golang have an full environment array?Of course it does. And so I reimplemented the code in my own project: envtmpl.Performance is not an issue here and I strongly believe that the template algorithm is going to be faster. It’s just intuition, however, if the template is parsed for tokens instead of search and replace strings… that much be faster unless scanning the document once for each key/value pair runs in O(1).