尝试执行此代码时出现一些内存错误:
package web
import (
"net/http"
"html/template"
)
type Hello struct {
Level string
}
func Main(w http.ResponseWriter, r *http.Request) {
h := Hello{Level: "gsdfg"}
t, _ := template.ParseFiles("web.html")
t.Execute(w, h)
}
我在浏览器中得到的错误信息是这样的:
the runtime process gave a bad HTTP response: ''
2015/03/26 11:34:56 http: panic serving 127.0.0.1:43269: runtime error: invalid memory address or nil pointer dereference
我不明白我做错了什么......
跃然一笑
慕仙森
相关分类