On the problem of passing parameters of golang function

ask a rookie question. Are (file * File) and (b [] byte) both incoming parameters in the following code? what"s the difference between them?

func (file *File) Write(b []byte) (n int, err error)
Jul.22,2021

Let me give you a hint: Write is a method, and the previous File is the receiver of this method, that is to say, Write is a method of type File

if you are a beginner, you should learn the language systematically

first.

to put it simply, methods and functions

(file * File) means that a method is declared to File. This parameter is the receiver, so the method we define is bound to the receiver and is called the receiver's method.
is not required, if not, it is purely a function accessed through the package name.

(b [] byte) is the function parameter

these are the basics, and it is suggested that students who are just getting started must figure it out.

Menu