My understanding of Golang method/function argument is that it works by call by value. But I came across this method call func (c *TCPConn) Read(b []byte) (int, error) where the argument is non pointer but it updates the variable value in caller. I think I am missing something. Pls help to understand this case.
>Solution :
It depends on the type of that argument. []byte is a slice and slices are actually pointers. Maps are also pointers so consider it when you use slice and Maps in your functions.
https://go.dev/blog/slices-intro:
A slice is a descriptor of an array segment. It consists of a pointer
to the array, the length of the segment, and its capacity (the maximum
length of the segment).