[go-nuts] text/template: Can't call method/function with 0 results.

2021-04-09 Thread 'Johnny Jacobs' via golang-nuts
Hello all, Is there any reason you can't use a custom function with no return value in Go templates? You get a "Can't call method/function with 0 results." if you try to call such a function. FuncMap requires functions to either return a value,

Re: [go-nuts] Re: text/template: Can't call method/function with 0 results.

2021-04-09 Thread 'Johnny Jacobs' via golang-nuts
I'm mostly thinking of functions with side-effects, much like {{ $var := "val" }}. It doesn't make much sense for these to return anything. Not allowing 0-valued functions limits functions you can call on objects in templates as well. For example, a trivial map implementation: type MyMap map[strin