We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Methods in Golang | Intermediate level
Summary
Description
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
Translated At: 2025-07-06T11:10:43Z