|
@@ -64,7 +64,7 @@ http.ListenAndServe(":8080", http.HandlerFunc(HelloServer))
|
|
|
2)`fmt.Fprint` 和 `fmt.Fprintf` 都是可以用来写入 `http.ResponseWriter` 的函数(他们实现了 `io.Writer`)。
|
|
2)`fmt.Fprint` 和 `fmt.Fprintf` 都是可以用来写入 `http.ResponseWriter` 的函数(他们实现了 `io.Writer`)。
|
|
|
比如我们可以使用
|
|
比如我们可以使用
|
|
|
```go
|
|
```go
|
|
|
-fmt.Fprintf(w, "<h1>%s<h1><div>%s</div>", title, body)
|
|
|
|
|
|
|
+fmt.Fprintf(w, "<h1>%s</h1><div>%s</div>", title, body)
|
|
|
```
|
|
```
|
|
|
来构建一个非常简单的网页并插入 `title` 和 `body` 的值。
|
|
来构建一个非常简单的网页并插入 `title` 和 `body` 的值。
|
|
|
|
|
|