Skip to content

W0701: No main package serves the folder routes ​

pages/route.go holds the module's folder routes as one option, pages.Routes(), and registers them on the app given it. The module has pages and a main package, and no main passes it to web.New, so none of them is served. vuka routes and vuka vet report it.

A module may hold several apps: a pages/ directory beside a package main is that main's folder routes, with its own route.go and urls, its paths from that pages/ (cmd/admin/pages/index.vuka.html is / of the cmd/admin app). Only the main beside it serves it, so W0701 is reported for it when that main doesn't pass its pages.Routes() to web.New. The module's own pages/ is served by any of its mains. A pages/ directory beside no main, other than the module's, is not folder routes.

Wrong ​

go
package main

import (
	_ "example.com/hr/pages"
	"github.com/vuka-lang/web/v2"
)

func main() { web.New().Run("") }
go
package main

import (
	"example.com/hr/pages"
	"github.com/vuka-lang/web/v2"
)

func main() { web.New(pages.Routes()).Run("") }

Fix ​

vuka fix routes adds the import and pages.Routes() to the web.New call of the main that owns the pages/ directory; vuka add page does it when it writes a page. When the module has several mains and none passes it, it is yours to add to the app that serves the pages.

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.