Sometimes I really feel it would help to quickly check this from the documentation. Knowing what types are implementing what is actually growing with experience, but it’s hard to remember them all. Testing this by hand each time is really annoying…
gopls will give a list of the interfaces a type implements. I don’t know the explicit gopls interaction, but in emacs, if you put point on a type and hit M-RET g i, it will list the interfaces it implements, and take you there if you pick one.
You could package this functionality into a library by using os.Exec to execute the code under a different process and seeing if it manages to compile.
I’m mostly joking, but tbh I’ve never been that desperate to know if something implements an interface.
This account has never commented and only posted links to their own blog. This is the definition of a spammer. Can an admin please boot them?
Sometimes I really feel it would help to quickly check this from the documentation. Knowing what types are implementing what is actually growing with experience, but it’s hard to remember them all. Testing this by hand each time is really annoying…
gopls
will give a list of the interfaces a type implements. I don’t know the explicitgopls
interaction, but in emacs, if you put point on a type and hitM-RET g i
, it will list the interfaces it implements, and take you there if you pick one.https://imgur.com/a/WHx5siT
You could package this functionality into a library by using
os.Exec
to execute the code under a different process and seeing if it manages to compile.I’m mostly joking, but tbh I’ve never been that desperate to know if something implements an interface.
I believe
would save you an alloc all together.
While that is theoretically correct, it turns out that
is compiled away, so there is no alloc to remove.