Skip to content

Commit

Permalink
Merge pull request gopl-zh#131 from StudentWeis/patch-1
Browse files Browse the repository at this point in the history
一个小翻译问题和 typo
  • Loading branch information
cch123 authored Oct 20, 2022
2 parents 1597ed7 + a1ad719 commit 9b5c4ea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ch5/ch5-09.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default:
}
```

断言函数必须满足的前置条件是明智的做法,但这很容易被滥用。除非你能提供更多的错误信息,或者能更快速的发现错误,否则不需要使用断言,编译器在运行时会帮你检查代码
断言函数必须满足的前置条件是明智的做法,但这很容易被滥用。除非你能提供更多的错误信息,或者能更快速的发现错误,否则不需要断言那些运行时会检查的条件

```Go
func Reset(x *Buffer) {
Expand Down
2 changes: 1 addition & 1 deletion ch6/ch6-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ fmt.Println(geometry.PathDistance(perim)) // "12", standalone function
fmt.Println(perim.Distance()) // "12", method of geometry.Path
```

**译注:** 如果我们要用方法去计算perim的distance,还需要去写全geometry的包名,和其函数名,但是因为Path这个类型定义了一个可以直接用的Distance方法,所以我们可以直接写perim.Distance()。相当于可以少打很多字,作者应该是这个意思。因为在Go里包外调用函数需要带上包名,还是挺麻烦的。
**译注:** 如果我们要用函数去计算perim的distance,还需要去写全geometry的包名,和其函数名,但是因为Path这个类型定义了一个可以直接用的Distance方法,所以我们可以直接写perim.Distance()。相当于可以少打很多字,作者应该是这个意思。因为在Go里包外调用函数需要带上包名,还是挺麻烦的。

0 comments on commit 9b5c4ea

Please sign in to comment.