Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
- [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- panic: html/template: pattern matches no files: `templates/*`
- goroutine 1 [running]:
- html/template.Must(0x0, 0xcd74c0, 0xc4201be240, 0x0)
- /usr/lib/go-1.9/src/html/template/template.go:364 +0x54
- github.com/gin-gonic/gin.(*Engine).LoadHTMLGlob(0xc4201fa000, 0xa3b76f, 0xb)
- /home/prince/go/src/github.com/gin-gonic/gin/gin.go:176 +0x4a2
- main.main()
- /media/prince/New Volume1/gin exercises /main.go:20 +0x5d
- exit status 2
- -templates
- -index.html
- -header.html
- -menu.html
- main.go
- package main
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- )
- var router *gin.Engine
- func main() {
- // Set the router as the default one provided by Gin
- router = gin.Default()
- // Process the templates at the start so that they don't have to be loaded
- // from the disk again. This makes serving HTML pages very fast.
- // Define the route for the index page and display the index.html template
- // To start with, we'll use an inline route handler. Later on, we'll create
- // standalone functions that will be used as route handlers.
- router.GET("/", func(c *gin.Context) {
- // Call the HTML method of the Context to render a template
- c.HTML(
- // Set the HTTP status to 200 (OK)
- http.StatusOK,
- // Use the index.html template
- "index.html",
- // Pass the data that the page uses (in this case, 'title')
- gin.H{
- "title": "Home Page",
- },
- )
- })
- // Start serving the application
- router.Run()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement