We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go里一共有4种函数:
调用的方式有5种:
package main func TopLevel(x int) {} type Pointer struct{} func (*Pointer) M(int) {} type Value struct{} func (Value) M(int) {} type Interface interface { M(int) } var literal = func(x int) {} func main() { // direct call of top-level func TopLevel(1) // direct call of method with value receiver (two spellings, but same) var v Value v.M(1) Value.M(v, 1) // direct call of method with pointer receiver (two spellings, but same) var p Pointer (&p).M(1) (*Pointer).M(&p, 1) // indirect call of func value (×4) f1 := TopLevel f1(1) f2 := Value.M f2(v, 1) f3 := (*Pointer).M f3(&p, 1) f4 := literal f4(1) // indirect call of method on interface (×3) var i Interface i = v i.M(1) i = &v i.M(1) i = &p i.M(1) Interface.M(i, 1) Interface.M(v, 1) Interface.M(&p, 1) }
综上,总共有10种函数与调用方式的组合:
//refer: https://docs.google.com/document/d/1bMwCey-gmqZVTpRax-ESeVuZGmjwbocYs1iHplK-cjo/pub
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Go里一共有4种函数:
调用的方式有5种:
综上,总共有10种函数与调用方式的组合:
//refer: https://docs.google.com/document/d/1bMwCey-gmqZVTpRax-ESeVuZGmjwbocYs1iHplK-cjo/pub
The text was updated successfully, but these errors were encountered: