You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It only works if value is not wrapped in an interface value (e.g. interface{}). In my opinion, a concrete slice value stored in an interface should be "extracted" and used.
What did you expect to see?
[1 2]<nil>
[1 2]<nil>
What did you see instead?
[1 2]<nil>
template: :1:2: executing "" at <slice .x 0 2>: error calling slice: reflect: call of reflect.Value.Slice on interface Value
The text was updated successfully, but these errors were encountered:
Always shadow or modify the original parameter name. With code like:
func index(item reflect.Value, ... {
v := indirectInterface(item)
It was possible to incorrectly use 'item' and 'v' later in the function,
which could result in subtle bugs. This is precisely the kind of mistake
that led to #36199.
Instead, don't keep both the old and new reflect.Value variables in
scope. Always shadow or modify the original variable.
While at it, simplify the signature of 'length', to receive a
reflect.Value directly and save a few redundant lines.
Change-Id: I01416636a9d49f81246d28b91aca6413b1ba1aa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/212117
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Roberto Clapis <robclap8@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to use the
slice
template function introduced in Go 1.13.Playground:
It only works if value is not wrapped in an interface value (e.g.
interface{}
). In my opinion, a concrete slice value stored in an interface should be "extracted" and used.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: