mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-10-21 06:12:53 +00:00
修复代码前的包路径
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
|
||||
爲了最簡單地展示基於HTTP獲取信息的方式,下面給出一個示例程序fetch,這個程序將獲取對應的url,併將其源文本打印出來;這個例子的靈感來源於curl工具(譯註:unix下的一個用來發http請求的工具,具體可以man curl)。當然,curl提供的功能更爲複雜豐富,這里隻編寫最簡單的樣例。這個樣例之後還會多次被用到。
|
||||
|
||||
<u><i>gopl.io/ch1/fetch</i></u>
|
||||
```go
|
||||
gopl.io/ch1/fetch
|
||||
// Fetch prints the content found at a URL.
|
||||
package main
|
||||
|
||||
@@ -66,4 +66,3 @@ fetch: Get http://gopl.io: dial tcp: lookup gopl.io: getaddrinfow: No such host
|
||||
**練習 1.8:** 脩改fetch這個范例,如果輸入的url參數沒有 `http://` 前綴的話,爲這個url加上該前綴。你可能會用到strings.HasPrefix這個函數。
|
||||
|
||||
**練習 1.9:** 脩改fetch打印出HTTP協議的狀態碼,可以從resp.Status變量得到該狀態碼。
|
||||
|
||||
|
Reference in New Issue
Block a user