原装代码 ,跑起来报错。。。

2019/03/12 16:45:02 http: panic serving [::1]:50978: runtime error: invalid memory address or nil pointer dereference
goroutine 35 [running]:
net/http.(conn).serve.func1(0xc00009ed20)
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:1746 +0xd0
panic(0x133a380, 0x1642e60)
/usr/local/Cellar/go/1.11.4/libexec/src/runtime/panic.go:513 +0x1b9
html/template.(
Template).escape(0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.11.4/libexec/src/html/template/template.go:95 +0x2e
html/template.(Template).Execute(0x0, 0x13f6360, 0xc000116000, 0x0, 0x0, 0xc0000832f0, 0xc000104080)
/usr/local/Cellar/go/1.11.4/libexec/src/html/template/template.go:119 +0x2f
main.login(0x13f9260, 0xc000116000, 0xc000110000)
/Users/lianzhang/go/src/me/hello.go:29 +0x33c
net/http.HandlerFunc.ServeHTTP(0x13b1958, 0x13f9260, 0xc000116000, 0xc000110000)
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:1964 +0x44
net/http.(
ServeMux).ServeHTTP(0x16519c0, 0x13f9260, 0xc000116000, 0xc000110000)
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:2361 +0x127
net/http.serverHandler.ServeHTTP(0xc000085110, 0x13f9260, 0xc000116000, 0xc000110000)
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:2741 +0xab
net/http.(conn).serve(0xc00009ed20, 0x13f9520, 0xc00008a200)
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:1847 +0x646
created by net/http.(
Server).Serve
/usr/local/Cellar/go/1.11.4/libexec/src/net/http/server.go:2851 +0x2f5

laopan1234
最佳答案

哦找到了。。是模板路径的问题。修改成绝对路径就Ok

1周前
讨论数量: 1
laopan1234

哦找到了。。是模板路径的问题。修改成绝对路径就Ok

1周前

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!