mirror of
https://github.com/gin-gonic/gin.git
synced 2025-12-15 14:17:03 +08:00
Using template.Must instead of catching errors manually
This commit is contained in:
parent
2ee8532a0e
commit
2398b5179d
@ -259,11 +259,7 @@ You can also use your own html template render
|
|||||||
import "html/template"
|
import "html/template"
|
||||||
func main() {
|
func main() {
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
html, err := template.ParseFiles("file1", "file2")
|
html := template.Must(template.ParseFiles("file1", "file2"))
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Could not parse templates: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.HTMLTemplates = html
|
r.HTMLTemplates = html
|
||||||
|
|
||||||
// Listen and server on 0.0.0.0:8080
|
// Listen and server on 0.0.0.0:8080
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user