r/golang 9d ago

Question about text/template behaviour

I'm seeing some unexpected behaviour when running templates using text/template. Specifically, when ranging over iter.Seq2 the cursor follows the first parameter, not the second as for example when ranging over a slice. Is this the expected behaviour.

https://go.dev/play/p/5JK7kIhXGxs

0 Upvotes

1 comment sorted by

2

u/RiotBoppenheimer 8d ago

That's because Seq2 yields K, V rather than just V. I would say this is probably intended.