I
I
impressive172020-04-24 21:08:49
go
impressive17, 2020-04-24 21:08:49

How to refer to struct field in golang html template?

Let's say there is a structure that I pass to the html template

type Mystruct struct{
  Mas[]int
  User User
}

The User structure is the following:
type User struct {
  Username      string
  Password      string
  Name          string
  Authenticated bool
}

How can I check the Authenticated variable in an HTML file?
For example, this doesn't work for me.
{{if .Authenticated }}
<p>NO</p>
{{else}}
<p>YES</p>
{{end}}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-04-24
@impressive17

so please contact
.User.Authenticated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question