Skip to content

Instantly share code, notes, and snippets.

@tiaguinho
Created January 17, 2022 10:25
import (
"embed"
"log"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html"
)
//go:embed views/*
var views embed.FS
func main() {
// Iniciamos a engine usando a váriavel views que criamos acima
engine := html.NewFileSystem(http.FS(views), ".html")
app := fiber.New(fiber.Config{
Views: engine,
})
app.Get("/", func(c *fiber.Ctx) error {
// Renderiza o template index.html
return c.Render("views/index", fiber.Map{
"Nome": "Tiago Temporin",
})
})
log.Fatal(app.Listen(":3000"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment