You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a long-living upstream issue about this (golang/go#53015) which I don't think is going to be fixed in Go anytime soon.
We do have some patches to Go's template execution package, so if the fix I have in mind for this isn't too intrusive in that package (as in: it makes it very hard to maintain the fork), I think it's worth to improve this situation.
We have added a return keyword, but it currently have some limiations:
It only works in partials.
It must be the last command in the template.
The current implementation, with its template transformations, has some complexities that would be great to rid of.
I have often wanted to return early, even from regular templates, which often avoids wrapping large block of templates in conditionals.
So, I suggest we have a look if it's feasible to introduce a sentinel error with an optional value (used in partials), so the template func (with the return alias) would be something ala:
Activity
tpl: Improve the return keyword in templates
tpl: Improve the return keyword in templates
tpl: Improve the return keyword in templates
github-actions commentedon Sep 10, 2026
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.