Skip to content

Instantly share code, notes, and snippets.

@billhathaway
Created July 29, 2014 23:23
Show Gist options
  • Save billhathaway/c745afd7fa334e76923a to your computer and use it in GitHub Desktop.
Save billhathaway/c745afd7fa334e76923a to your computer and use it in GitHub Desktop.
joining strings in confd templates
With confd sometimes you will want to join a bunch of keys together into a line with comma separated values. Here is a template snippet to do that:
servers={{range $index,$server := .myapp_servers}}{{if $index}},"{{$server.Value}}"{{else}}"{{$server.Value}}"{{end}}{{end}}
Credit for the technique goes to Jan Newmarch's tutorial page at http://jan.newmarch.name/go/template/chapter-template.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment