consider using generics to aid the constructor magic #1210
Labels
effort/days
Estimated to take multiple days, but less than a week
exp/intermediate
Prior experience is likely helpful
kind/enhancement
A net-new feature or improvement to an existing feature
status/blocked
Unable to be worked further until needs are met
I think the design makes sense. My only worry as a user is that
opts ...interface{}
is very unsafe at a static level, but I don't think you can do any better without generics. Once you had generics, you could do funky stuff like:Note that this would not support arbitrary parameters before the variadic options, like the upgrader in
func NewTCPTransport(upgrader *tptu.Upgrader, opts ...Option)
. I don't think 1.18 generics has support for "arbitrary parameters" like that. But perhaps those could be redesigned to fit generics, to perhaps even remove the need for reflection.Very much getting off-topic here. Just food for thought, in case you considered generics :)
Originally posted by @mvdan in #1205 (review)
The text was updated successfully, but these errors were encountered: