Chúng tôi không thể tìm thấy kết nối internet
Đang cố gắng kết nối lại
Có lỗi xảy ra!
Hãy kiên nhẫn trong khi chúng tôi khắc phục sự cố
Các phương thức trong Golang | Cấp độ trung cấp
Tóm tắt nội dung
Mô tả
Explains how methods work in Go, things like method normalization, method value evaluation, gotchas and best practices. It also explains the reasons for choosing between pointer and value receiver.
0:00 Basics of Methods
1:21 Value vs Pointer receivers
2:55 Methods on nil values
3:44 Pass by copy
5:54 Pass by copy with slices
7:58 Method normalization
9:25 Method value evaluation
11:01 Gotcha - calling method in range loop
12:26 New types won't get methods of base type
12:53 Choosing between pointer and value receiver
Intermediate level Golang playlist: https://youtu.be/RVTfPy_NELc?list=PLSozy2hb5kKPpIJnpZ2sSMfjVjP0tyJYG
Dave Cheney's blog posts:
https://dave.cheney.net/2016/03/19/should-methods-be-declared-on-t-or-t
https://dave.cheney.net/2015/11/18/wednesday-pop-quiz-spot-the-race
Code review wiki: https://github.com/golang/go/wiki/CodeReviewComments#receiver-type
Dịch Vào Lúc: 2025-07-06T11:10:43Z