Closed JustinJudd closed 3 years ago
$ genji version Genji v0.10.0 Genji CLI v0.10.0
Yes
package main import ( "fmt" "log" "github.com/genjidb/genji" "github.com/genjidb/genji/document" ) type User struct { Name string Reviews []*Review } type Review struct { Item string Review string Rating int } func main() { db, err := genji.Open(":memory:") if err != nil { log.Fatal(err) } db.Exec("CREATE table users") u := User{ Name: "Foo", Reviews: []*Review{ &Review{"Harry Potter", "Great Book", 9}, }, } db.Exec("INSERT INTO users VALUES ?", &u) var users []User res, err := db.Query("SELECT * FROM users") if err != nil { log.Fatal(err) } defer res.Close() err = res.Iterate(func(d document.Document) error { var u User err = document.StructScan(d, &u) if err != nil { return err } users = append(users, u) return nil }) if err != nil { log.Fatal(err) } fmt.Println("Users:", users) }
Users: [{Foo [0xc0000a4ab0]}]
panic: reflect.Set: value of type **main.Review is not assignable to type *main.Review
$ go version go version go1.15.7 linux/amd64
go env
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/justin/.cache/go-build" GOENV="/home/justin/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/justin/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/justin/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build523484142=/tmp/go-build -gno-record-gcc-switches"
Thanks @JustinJudd! I have written a fix, I will create a patch release today
Patch: https://github.com/genjidb/genji/releases/tag/v0.10.1
Thanks for such a quick response!
What version of Genji are you using?
Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
Users: [{Foo [0xc0000a4ab0]}]
What did you see instead?
panic: reflect.Set: value of type **main.Review is not assignable to type *main.Review
What Go version and environment are you using?
go env
Output