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

2021-04-09 Thread 'Thomas Bushnell BSG' via golang-nuts
I find the current behavior clearer. What would you like a no-valued
function to insert in the template? Even if it was the zero value, that
could be the string-typed zero value, or the int-typed zero value, and so
forth.

It could be defined, but why not make it explicit if you want it to insert
nothing, and return the empty string?

On Fri, Apr 9, 2021 at 2:05 PM 'Johnny Jacobs' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> 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, or a value plus an error.
>
> Is there any reason, technical or otherwise, for these restrictions?
> Variables assignment and many Action clauses don't give back values, so it
> doesn't seem like it breaks convention.
>
> I might file an issue for this if nothing meaningful is brought up here.
>
> Best,
> Johnny
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/fdb52e84-0cea-4269-9016-cc1d5064cc5bn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2BYjuxvQrf4zbvuDih3_QHHXHnC9f2CuuyY%3DKPfjKOOkT6y8dQ%40mail.gmail.com.


[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, or a value plus an error.

Is there any reason, technical or otherwise, for these restrictions? 
Variables assignment and many Action clauses don't give back values, so it 
doesn't seem like it breaks convention.

I might file an issue for this if nothing meaningful is brought up here.

Best,
Johnny

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fdb52e84-0cea-4269-9016-cc1d5064cc5bn%40googlegroups.com.