Skip to content

fix(confusions): rename invalid interface testing.TB to TB #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ch1-basic/ch1-04-func-method-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,12 @@ type proto.Message interface {
}
```

Interface `proto.Message` rất dễ bị "giả mạo", để tránh điều đó ta nên định nghĩa một phương thức riêng cho nó. Chỉ các đối tượng thỏa mãn phương thức riêng này mới có thể thỏa mãn interface đó và tên của phương thức riêng chứa tên đường dẫn tuyệt đối của package, vì vậy phương thức này chỉ có thể được hiện thực bên trong package để đáp ứng interface. `testing.TB` là interface trong package `test` sử dụng kỹ thuật này:
Interface `proto.Message` rất dễ bị "giả mạo", để tránh điều đó ta nên định nghĩa một phương thức riêng tư (private) cho nó. Chỉ các đối tượng thỏa mãn phương thức riêng này mới có thể thỏa mãn interface đó. `TB` là interface trong package `testing` sử dụng kỹ thuật này:

```go
type testing.TB interface {
package testing

type TB interface {
Error(args ...interface{})
Errorf(format string, args ...interface{})
...
Expand Down