ToSliceE: unable to cast []somestruct to []interface{}
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4k
- Forks
- 337
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
Playground: https://play.golang.org/p/5bbxzoB4jNw
package main
import (
"fmt"
"github.com/spf13/cast"
)
func main() {
b := []B{{Foo: "one"},{Foo: "two"}}
bees, err := cast.ToSliceE(b)
if err != nil {
panic(err)
}
fmt.Printf("bees: %+v\n", bees)
}
type B struct {
Foo string
}
panic: unable to cast []main.B{main.B{Foo:"one"}, main.B{Foo:"two"}} of type []main.B to []interface{}
goroutine 1 [running]:
main.main()
/tmp/sandbox460370487/prog.go:14 +0x157
Program exited: status 2.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ToSliceE entry point and reproduce the supplied playground example with []B. Determine why the []B value is rejected as []interface{}, then verify that the example completes without the reported panic and preserves both struct values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100