Re:Deadcode: Finding unreachable functions in Go
by erik_seaberg on Tuesday January 23, 2024 @03:51PM
(#39109616)
Yeah, you can look up a method but only if you already have the receiver’s type (which you also can’t look up by name, or by listing a package).
[ Parent
| on HN ]
Re:Deadcode: Finding unreachable functions in Go
by zimpenfish on Tuesday January 23, 2024 @05:19PM
(#39110761)
You don't need the receiver's type because you're calling `MethodByName` on a `reflect.Value` which you can construct from any receiver.
https://go.dev/play/p/hg-ugl7i0ei demonstrates this, I think?