I
I
impressive172020-05-08 22:11:48
go
impressive17, 2020-05-08 22:11:48

How to check array length in Golang html templates?

How to check array length in Golang html templates?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mamonov, 2020-05-08
@EvgenyMamonov

This is how you can

{{ $length := len .YourArray }}
{{ if eq $length 0 }}
    array has zero length
{{ end }}

You can just get the size like this
{{ len .YourArray }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question