Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
  2.  
  3. [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
  4.  
  5. panic: html/template: pattern matches no files: `templates/*`
  6.  
  7. goroutine 1 [running]:
  8. html/template.Must(0x0, 0xcd74c0, 0xc4201be240, 0x0)
  9. /usr/lib/go-1.9/src/html/template/template.go:364 +0x54
  10. github.com/gin-gonic/gin.(*Engine).LoadHTMLGlob(0xc4201fa000, 0xa3b76f, 0xb)
  11. /home/prince/go/src/github.com/gin-gonic/gin/gin.go:176 +0x4a2
  12. main.main()
  13. /media/prince/New Volume1/gin exercises /main.go:20 +0x5d
  14. exit status 2
  15.  
  16. -templates
  17. -index.html
  18. -header.html
  19. -menu.html
  20. main.go
  21.  
  22. package main
  23.  
  24. import (
  25. "net/http"
  26.  
  27. "github.com/gin-gonic/gin"
  28. )
  29.  
  30. var router *gin.Engine
  31.  
  32. func main() {
  33.  
  34. // Set the router as the default one provided by Gin
  35. router = gin.Default()
  36.  
  37. // Process the templates at the start so that they don't have to be loaded
  38. // from the disk again. This makes serving HTML pages very fast.
  39.  
  40. // Define the route for the index page and display the index.html template
  41. // To start with, we'll use an inline route handler. Later on, we'll create
  42. // standalone functions that will be used as route handlers.
  43. router.GET("/", func(c *gin.Context) {
  44.  
  45. // Call the HTML method of the Context to render a template
  46. c.HTML(
  47. // Set the HTTP status to 200 (OK)
  48. http.StatusOK,
  49. // Use the index.html template
  50. "index.html",
  51. // Pass the data that the page uses (in this case, 'title')
  52. gin.H{
  53. "title": "Home Page",
  54. },
  55. )
  56.  
  57. })
  58.  
  59. // Start serving the application
  60. router.Run()
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement