Get one value from a function that returns multiple values


I’m trying to understand how to get the week number of a post. I saw there’s a ISOWeek function, but it returns two values (year and week number). I’ve tried something like:

$year, $week := .Date.ISOWeek

but Hugo’s logs say

can’t call method/function “ISOWeek” with 2 results

so I guess the function is reachable but you can’t set variables this way inside a template.

Is there a way to get just one of two values?

1 Like

I would love to know how to get one result from the above but I don’t think it’s possible in a Hugo’s Go Template context. (see go - Using methods with multiple return values - Stack Overflow)

I made a proposal to surface a .Week method on the object returned by time and now