Skip to content

E0147: A template file declares more than one struct ​

A .vuka.html file renders one struct, declared in the Go above its markup. The file declares two or more, so which one the markup renders isn't said by the file. The error is at the second.

Wrong ​

html
<!-- page.vuka.html -->
<script lang="go">
package pages

type Page struct {
	Rows []Row
}

type Row struct {
	ID int
}
</script>

<ul>…</ul>

A struct with markup of its own goes in its own .vuka.html file; one without markup — data, a form's fields — goes in a .go file:

go
// row.go
package pages

type Row struct {
	ID int
}
html
<!-- page.vuka.html -->
<script lang="go">
package pages

type Page struct {
	Rows []Row
}
</script>

<ul>…</ul>

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.