有时候需要往浏览器访问的页面中输出调试信息,可以使用以下方法
import ( "fmt" "html/template" "io" "log" "net/http" ) func writeHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello")) io.WriteString(w, "hello io.writestring") fmt.Fprintf(w, "abc") return }