Reputation: 1241
With reference to this code
How to interpret this code?
(*http.ResponseWriter)(nil)
Is it type assertion or something else? I dont understand.
Also can interfaces have pointers?
Thanks
Upvotes: 0
Views: 85
Reputation: 24808
It's a nil
pointer.
nil
pointers have a type, in this case it's *http.ResponseWriter
.
Edit to answer question in comment section:
The reason for doing this is that inject
(Martini's dependency injector) maps an interface type to an implementation of that interface through MapTo
.
As it's really only interested in the interface's type (as second argument), a nil
pointer is enough.
Upvotes: 1