Answer the question
In order to leave comments, you need to log in
Why in Go HTTP handlers is ResponseWriter a value and request a pointer?
why is the Request object a pointer and ResponseWriter not a pointer? Is there a need for this or is it just to make some advanced pointer based code possible?
Answer the question
In order to leave comments, you need to log in
ResponseWriter is an interface.
Thus, the argument is the implementation of this interface (instance), which is still passed by pointer.
ResponseWriter is an interface . It is not customary to pass an interface type to a function by reference UsePointer(* SomeInterface ) because such an argument is hard to construct. Even if your MyResponseWriter type satisfies the ResponseWriter interface, you would have to
MyOwnWriter := ResponseWriter(MyResponseWriter)
MyArgument := &MyOwnWriter
//и только потом
UsePointer(MyArgument)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question