I can make Go more generic and reuse code. As I use Go templates and populate them with sql data just before rendering.
Go is smaller in the sense that it is more reusable than Javascropt and can be more generic. And more maintainable.
Here is the “base.html” that works as a template for all other pages:
<!DOCTYPE html>
<html lang="en">
{{template "httphead"}}
<body data-theme="default">
{{template "icn"}} {{template "nav"}}
<main>
{{template "header"}}
<div id="content"></div>
</main>
{{template "httpend"}}
</body>
</html>
and the content in a Go sub template for navigation. Filled by a generic function for every page:
<ul id="mainlist">
{{ range . }}
<li id="{{.menu_id}}" onclick='submenus({{.menu_id}},{{.menu_sub}})' )>
<svg class="icn56"><use xlink:href="{{.menu_icn}}" /></svg
><span>{{.menu_txt}}</span>
</li>
{{ end }}
</ul>
The rendering of all pages is also generic.
This is Javascript code that you have to repeat for each and every list or template. At least I have no clue how to make it generic. And I guess you have to add the HTML stuff making the code even bigger.
function filllist1(data) {
let mainlist = document.getElementById("mainlist");
data.forEach(function(item) {
let li = document.createElement('li')
li.setAttribute('id', item.menu_id)
li.innerHTML = `<a href="` + item.menu_lnk + `"><svg class="icn56"><use xlink:href="` + item.menu_icn + `"/></svg>` + item.menu_txt + `</a>`
mainlist.appendChild(li)
})
}
function filllist2(data) {
let mainlist = document.getElementById("tsklist");
data.forEach(function(item) {
let li = document.createElement('li')
li.setAttribute('id', item.tsk_id)
li.innerHTML = `<a href="` + item.tsk_lnk + `"><svg class="icn57"><use xlink:href="` + item.tsk_icn + `"/></svg>` + item.tsk_txt + `</a>`
mainlist.appendChild(li)
})
}
....And so on for each and every list/table etc...
Go uses html templates which is very easy to maintain.
But Javascript code must be unique for each table or list. This generates tons of Javascript functions. (disclaimer: I have not found any way to make it generic)
And the main reason I avoid Javascript if I can is that you have to fill the content (table, list or whatever) in a callback function. But this is a personal opinion…