I tried your tutorials about web programming and I have an issue:
https://golang.org/doc/articles/wiki/
I have copied the code provided here and did everything like it is said and when I run the code and open server it displays this message:
pi@raspberrypi:~/go/src/github.com/harisgen79/go_crash_course/08_web $ ./main
2019/05/18 14:14:01 http: panic serving [::1]:36078: runtime error: invalid memory address or nil pointer dereference
goroutine 20 [running]:
net/http.(*conn).serve.func1(0x249c6c0)
/usr/local/go/src/net/http/server.go:1769 +0xf0
panic(0x317380, 0x5fb730)
/usr/local/go/src/runtime/panic.go:522 +0x1a0
html/template.(*Template).escape(0x0, 0x0, 0x0)
/usr/local/go/src/html/template/template.go:95 +0x24
html/template.(*Template).Execute(0x0, 0x3cfd28, 0x2518000, 0x30f430, 0x0, 0x3cfe00, 0x25020e0)
/usr/local/go/src/html/template/template.go:119 +0x1c
main.renderTemplate(0x3d24c0, 0x2518000, 0x3512d8, 0x4, 0x0)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:35 +0xd0
main.viewHandler(0x3d24c0, 0x2518000, 0x24f2180)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:41 +0x74
net/http.HandlerFunc.ServeHTTP(0x36d1d0, 0x3d24c0, 0x2518000, 0x24f2180)
/usr/local/go/src/net/http/server.go:1995 +0x34
net/http.(*ServeMux).ServeHTTP(0x602f58, 0x3d24c0, 0x2518000, 0x24f2180)
/usr/local/go/src/net/http/server.go:2375 +0x1ac
net/http.serverHandler.ServeHTTP(0x249e200, 0x3d24c0, 0x2518000, 0x24f2180)
/usr/local/go/src/net/http/server.go:2774 +0x88
net/http.(*conn).serve(0x249c6c0, 0x3d2ac0, 0x240c080)
/usr/local/go/src/net/http/server.go:1878 +0x7e4
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2884 +0x298
2019/05/18 14:14:01 http: panic serving [::1]:36080: runtime error: invalid memory address or nil pointer dereference
goroutine 21 [running]:
net/http.(*conn).serve.func1(0x249c720)
/usr/local/go/src/net/http/server.go:1769 +0xf0
panic(0x317380, 0x5fb730)
/usr/local/go/src/runtime/panic.go:522 +0x1a0
html/template.(*Template).escape(0x0, 0x0, 0x0)
/usr/local/go/src/html/template/template.go:95 +0x24
html/template.(*Template).Execute(0x0, 0x3cfd28, 0x2518090, 0x30f430, 0x0, 0x3cfe00, 0x2502260)
/usr/local/go/src/html/template/template.go:119 +0x1c
main.renderTemplate(0x3d24c0, 0x2518090, 0x3512d8, 0x4, 0x0)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:35 +0xd0
main.viewHandler(0x3d24c0, 0x2518090, 0x2538080)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:41 +0x74
net/http.HandlerFunc.ServeHTTP(0x36d1d0, 0x3d24c0, 0x2518090, 0x2538080)
/usr/local/go/src/net/http/server.go:1995 +0x34
net/http.(*ServeMux).ServeHTTP(0x602f58, 0x3d24c0, 0x2518090, 0x2538080)
/usr/local/go/src/net/http/server.go:2375 +0x1ac
net/http.serverHandler.ServeHTTP(0x249e200, 0x3d24c0, 0x2518090, 0x2538080)
/usr/local/go/src/net/http/server.go:2774 +0x88
net/http.(*conn).serve(0x249c720, 0x3d2ac0, 0x2502140)
/usr/local/go/src/net/http/server.go:1878 +0x7e4
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2884 +0x298
2019/05/18 14:14:02 http: panic serving [::1]:36082: runtime error: invalid memory address or nil pointer dereference
goroutine 5 [running]:
net/http.(*conn).serve.func1(0x255e000)
/usr/local/go/src/net/http/server.go:1769 +0xf0
panic(0x317380, 0x5fb730)
/usr/local/go/src/runtime/panic.go:522 +0x1a0
html/template.(*Template).escape(0x0, 0x0, 0x0)
/usr/local/go/src/html/template/template.go:95 +0x24
html/template.(*Template).Execute(0x0, 0x3cfd28, 0x2518120, 0x30f430, 0x0, 0x3cfe00, 0x25023c0)
/usr/local/go/src/html/template/template.go:119 +0x1c
main.renderTemplate(0x3d24c0, 0x2518120, 0x3512d8, 0x4, 0x0)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:35 +0xd0
main.viewHandler(0x3d24c0, 0x2518120, 0x2538100)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:41 +0x74
net/http.HandlerFunc.ServeHTTP(0x36d1d0, 0x3d24c0, 0x2518120, 0x2538100)
/usr/local/go/src/net/http/server.go:1995 +0x34
net/http.(*ServeMux).ServeHTTP(0x602f58, 0x3d24c0, 0x2518120, 0x2538100)
/usr/local/go/src/net/http/server.go:2375 +0x1ac
net/http.serverHandler.ServeHTTP(0x249e200, 0x3d24c0, 0x2518120, 0x2538100)
/usr/local/go/src/net/http/server.go:2774 +0x88
net/http.(*conn).serve(0x255e000, 0x3d2ac0, 0x25022a0)
/usr/local/go/src/net/http/server.go:1878 +0x7e4
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2884 +0x298
2019/05/18 14:14:07 http: panic serving [::1]:36084: runtime error: invalid memory address or nil pointer dereference
goroutine 22 [running]:
net/http.(*conn).serve.func1(0x249c780)
/usr/local/go/src/net/http/server.go:1769 +0xf0
panic(0x317380, 0x5fb730)
/usr/local/go/src/runtime/panic.go:522 +0x1a0
html/template.(*Template).escape(0x0, 0x0, 0x0)
/usr/local/go/src/html/template/template.go:95 +0x24
html/template.(*Template).Execute(0x0, 0x3cfd28, 0x25181b0, 0x30f430, 0x0, 0x3cfe00, 0x2502520)
/usr/local/go/src/html/template/template.go:119 +0x1c
main.renderTemplate(0x3d24c0, 0x25181b0, 0x3512d8, 0x4, 0x0)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:35 +0xd0
main.viewHandler(0x3d24c0, 0x25181b0, 0x2538180)
/home/pi/go/src/github.com/harisgen79/go_crash_course/08_web/main.go:41 +0x74
net/http.HandlerFunc.ServeHTTP(0x36d1d0, 0x3d24c0, 0x25181b0, 0x2538180)
/usr/local/go/src/net/http/server.go:1995 +0x34
net/http.(*ServeMux).ServeHTTP(0x602f58, 0x3d24c0, 0x25181b0, 0x2538180)
/usr/local/go/src/net/http/server.go:2375 +0x1ac
net/http.serverHandler.ServeHTTP(0x249e200, 0x3d24c0, 0x25181b0, 0x2538180)
/usr/local/go/src/net/http/server.go:2774 +0x88
net/http.(*conn).serve(0x249c780, 0x3d2ac0, 0x2502400)
/usr/local/go/src/net/http/server.go:1878 +0x7e4
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2884 +0x298
^C
It just stops like this and I have to terminate it as you can see.
I’m using Raspberry Pi 3 model B. Anyone knows why is this happening?