S
S
s_pyanov2016-10-24 14:50:45
go
s_pyanov, 2016-10-24 14:50:45

How to write a frontend for a web application in go?

In continuation of the topic How to display the values ​​of a variable on an html page in go?
Tell me - if I need, for example, to transfer a whole array from the go application to the html page, then how should I process it, how to access one or another array element (and string)? I'm really bad at this stuff. I assume that I need to use some hooks in the go program for requests from html pages? and on html pages to write scripts on ("something" / java-script?) that will send get / post to the application? Or am I fundamentally wrong? Tell me the direction please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bnytiki, 2016-10-24
@s_pyanov

Have you read this?
https://golang.org/doc/articles/wiki/#tmp_6
An example of working with an array:
In the html template, write like this

<ul>
{{range .}}
<li>{{.Item}}</li>
{{end}}
</ul>

In the text in Go, this corresponds to something like this:
array:= []string{"abba", "bo", "rat"}
ExecuteTemplate("templateName", arrray)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question