ch7: fix code format

This commit is contained in:
chai2010
2016-01-21 10:22:10 +08:00
parent 2420954025
commit 0b5ec941ed
13 changed files with 208 additions and 186 deletions

View File

@@ -2,8 +2,8 @@
在本章我們會學到另一個標準的接口類型flag.Value是怎麽幫助命令行標記定義新的符號的。思考下面這個會休眠特定時間的程序
<u></i>gopl.io/ch7/sleep</i></u>
```go
// gopl.io/ch7/sleep
var period = flag.Duration("period", 1*time.Second, "sleep period")
func main() {
@@ -51,8 +51,8 @@ String方法格式化標記的值用在命令行幫組消息中這樣每一
讓我們定義一個允許通過攝氏度或者華氏溫度變換的形式指定溫度的celsiusFlag類型。註意celsiusFlag內嵌了一個Celsius類型(§2.5)因此不用實現本身就已經有String方法了。爲了實現flag.Value我們隻需要定義Set方法
<u><i>gopl.io/ch7/tempconv</i></u>
```go
// gopl.io/ch7/tempconv
// *celsiusFlag satisfies the flag.Value interface.
type celsiusFlag struct{ Celsius }
@@ -89,8 +89,8 @@ func CelsiusFlag(name string, value Celsius, usage string) *Celsius {
現在我們可以開始在我們的程序中使用新的標記:
<u><i>gopl.io/ch7/tempflag</i></u>
```go
// gopl.io/ch7/tempflag
var temp = tempconv.CelsiusFlag("temp", 20.0, "the temperature")
func main() {