Function to get struct field by name?

Is there a function to get a field by name, similar to index but applied to structs for example resource.Image?

I mean something like this:

$image := <get image from resources>
$imageLink := getField $image "Permalink"

This example is trivial, but I have a slice of images I want to convert to a slice of image links and it would be handy to use ´apply´ with that function instead of creating manually the slice. I tried index but it doesn’t work on structs.


Yeah, for a “bar” field in struct object “foo”, you can access that field only by doing “”.

This can be alleviated if Hugo added a struct to map conversion if it used something like this:


The struct debug in my debugprint partial would get much simpler if that struct to map decoding were done.