How can I create a function in Go Templates? I am trying to loop through a directory tree passed into the template, but I don't know how to go about looping through subdirectories without creating a function in the template that'll call itself.
Here is some pseudocode for what I would like to do:
function loop(directory){
for item in directory:
if item.type == FOLDER:
loop(item)
}
If anything's unclear, I'd be happy to clarify.