This is a creation in Article, where the information may have evolved or changed.
conn, err = ln. Accept () go handleconnection (conn)
See here I have a question, why not handleconnection (&conn)?
Package Mainimport ("FMT") type Interface Interface {say () String}type Object struct {}func (this *object) say () St Ring {return "Hello"}func do (i Interface) string {return I.say ()}func main () {o: = object{} fmt. Println (Do (&o)) fmt. Printf ("Ccccccccccc:%t", O)}
The parameters of the function are defined by the interface, and the compiler determines itself whether the argument is an object or a pointer to the object
For example, say is a method on a pointer, so do only accept pointers to object as arguments, do (o) is compiled
So when you see the library interface as a parameter type definition, you can simply think that this interface is definitely an object pointer (although you can also use the object, single estimate no class library will be used)
For example:
conn, err = ln. Accept () go handleconnection (conn)
Here conn is an interface, do not need go handleconnection (&conn)