goについて勉強しています。以下のサンプルが動かないので、理由がわからないので教えてください。
server.go
package main import ( "html/template" "net/http" ) func process(w http.ResponseWriter, r *http.Request) { t, _ := template.ParseFiles("tmpl.html") t.Execute(w, "Hello World!") } func main() { server := http.Server{ Addr: "127.0.0.1:9000", } http.HandleFunc("/process", process) server.ListenAndServe() }
tmpl.html
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Go Web Programming</title> </head> <body> {{ . }} </body> </html>
go1.9を利用しています。根本的によくわからないのでよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/12 02:10
2017/09/13 04:23