mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-11-23 03:12:14 +00:00
第5章,部分字词修订。
This commit is contained in:
@@ -103,11 +103,9 @@ func lookup(key string) int {
|
||||
<u><i>gopl.io/ch5/trace</i></u>
|
||||
```Go
|
||||
func bigSlowOperation() {
|
||||
defer trace("bigSlowOperation")() // don't forget the
|
||||
extra parentheses
|
||||
defer trace("bigSlowOperation")() // don't forget the extra parentheses
|
||||
// ...lots of work…
|
||||
time.Sleep(10 * time.Second) // simulate slow
|
||||
operation by sleeping
|
||||
time.Sleep(10 * time.Second) // simulate slow operation by sleeping
|
||||
}
|
||||
func trace(msg string) func() {
|
||||
start := time.Now()
|
||||
@@ -169,8 +167,7 @@ for _, filename := range filenames {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close() // NOTE: risky; could run out of file
|
||||
descriptors
|
||||
defer f.Close() // NOTE: risky; could run out of file descriptors
|
||||
// ...process f…
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user