Skip to content

E0146: A template file's Go declares no struct ​

A .vuka.html file whose Go comes before its markup renders one struct, declared in that Go: the markup is the struct's view, its fields read by bare name. The file's Go declares none — only variables, functions, or types that aren't structs.

Wrong ​

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

var greeting = "hello"
</script>

<p>{greeting}</p>

Declare the struct the markup renders:

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

type Page struct {
	Greeting string
}
</script>

<p>{Greeting}</p>

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.