<分区>
我正在通过 go 服务 index.html。但是,根据将通过页面发送的某些参数,go 应该成功重定向到不同的页面。尝试执行代码时出现以下错误。
http: 多次响应.WriteHeader 调用
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[1:])
fmt.Println(r.FormValue("login"))
if r.FormValue("signup") == "signup" {
signup(w, r)
} else if r.FormValue("login") == "login" {
if login(w, r) {
if r.Method == "POST" {
fmt.Println("I m here")
http.Redirect(w, r, "http://localhost:8080/home.html" (http://localhost:8080/home.html') , http.StatusSeeOther)
}
}
}
})
var port string
if port = os.Getenv("PORT"); len(port) == 0 {
port = DEFAULT_PORT
}
log.Fatal(http.ListenAndServe(":"+port, nil))
}