Add internal/reflectlite
package support.
#994
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This package is meant to be a cut-down version of the
reflect
package,which is used by packages like
errors
to avoid a cyclic dependencywith
reflect
.This code is based on goplusjs/gopherjs@8e608e5.
The natives code of the reflectlite package is a subset of its
counterpart from reflect. Unfortunately, this requires us to duplicate
a substantial chunk of code with all the maintenance problems that stem
from it. I have considered two alternative approaches, none of which
worked out:
internal/reflectlite
toreflect
. Unfortunately, this creates cyclic dependencies andcauses compilation to fail.
counterparts. This both causes a cyclic dependency and creates a
divergence between GopherJS and Go standard library. TinyGo seems to
be doing that somehow, but I suspect that they are able to handle
cyclic dependencies.
As a bottom line, duplicating a subset of reflect code is the lesser
evil that is available to us. In the long term we could try and converge
our reflect implementation with the upstream, so that this is no longer
our problem.
Updates #989.
Co-authored-by: visualfc visualfc@gmail.com