此功能发生了什么? [关闭]

I am failing to understand whats happening with Equal (u T) bool. Is it a method within a function? Also what is the difference of a method and a function. I understand that this function is taking in t of type T and return true or false if t=u.

 type T int 
 func (t T) Equal (u T) bool {return t==u}

That's a method declaration, and since methods in Go are just functions with a receiver they are declared using the keyword func.

func (t T) Equal (u T) bool {return t==u}
1     2 3  4      5 6  7     8
  1. the keyword used to declare functions and methods.
  2. the method receiver's identifier, using this you can access the receiver inside the body of the method.
  3. the method receiver's type.
  4. the name of the method.
  5. the name of the method's argument, using this you can access the argument inside the body of the method.
  6. the type of the method's argument.
  7. the return type of the method argument.
  8. the body of the method.

For comparison, a function that does the same thing would be declared as such:

func Equal (t T, u T) bool {return t==u}

(no reciever, but takes two arguments)