capnproto / go-capnp

Cap'n Proto library and code generator for Go

Home Page:https://capnproto.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

example/books/ex1 does not work with go-1.21.6

spikebike opened this issue · comments

When I try to run the books example I get:

test@282ab995ca3d:~/go-capnp/example/books/ex1$ go build .
# books
../books/books.capnp.go:37:25: capnp.Struct(s).EncodeAsPtr undefined (type capnp.Struct has no field or method EncodeAsPtr)
../books/books.capnp.go:41:29: capnp.Struct{}.DecodeFromPtr undefined (type capnp.Struct has no field or method DecodeFromPtr)
../books/books.capnp.go:85:18: type instantiation requires go1.18 or later (-lang was set to go1.17; check go.mod)
../books/books.capnp.go:85:24: undefined: capnp.StructList
../books/books.capnp.go:90:15: undefined: capnp.StructList
../books/books.capnp.go:97:21: f.Future.Ptr undefined (type *capnp.Future has no field or method Ptr)

If I change go.mod to 1.21 I get the same errors, except for the "type instantiation requires go1.18" problem. To replicate with podman:

apt install podman
podman pull ubuntu
podman run -it --name my-ubuntu ubuntu
apt update
apt install wget -y capnproto git
cd /tmp
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz
adduser test
su - test
export PATH=~/pkg/go/bin:/usr/local/go/bin:$PATH
export GOPATH=/home/test/pkg/go
go install capnproto.org/go/capnp/v3/capnpc-go@latest
git clone https://github.com/capnproto/go-capnp
cd ~/go-capnp/example/books
capnp compile -I ../../std/ -ogo books/books.capnp
test@282ab995ca3d:~/go-capnp/example/books$ cd ex1 && go build .
go: downloading capnproto.org/go/capnp/v3 v3.0.0-alpha.1
# books
../books/books.capnp.go:37:25: capnp.Struct(s).EncodeAsPtr undefined (type capnp.Struct has no field or method EncodeAsPtr)
../books/books.capnp.go:41:29: capnp.Struct{}.DecodeFromPtr undefined (type capnp.Struct has no field or method DecodeFromPtr)
../books/books.capnp.go:85:18: type instantiation requires go1.18 or later (-lang was set to go1.17; check go.mod)
../books/books.capnp.go:85:24: undefined: capnp.StructList
../books/books.capnp.go:90:15: undefined: capnp.StructList
../books/books.capnp.go:97:21: f.Future.Ptr undefined (type *capnp.Future has no field or method Ptr)

I tried it with go1.22.0, same problem, same script as above except for the go 1.22.0 version:

test@9cea4defcf09:~/go-capnp/example/books$ cd ex1 && go build .
go: downloading capnproto.org/go/capnp/v3 v3.0.0-alpha.1
# books
../books/books.capnp.go:37:25: capnp.Struct(s).EncodeAsPtr undefined (type capnp.Struct has no field or method EncodeAsPtr)
../books/books.capnp.go:41:29: capnp.Struct{}.DecodeFromPtr undefined (type capnp.Struct has no field or method DecodeFromPtr)
../books/books.capnp.go:85:18: type instantiation requires go1.18 or later (-lang was set to go1.17; check go.mod)
../books/books.capnp.go:85:24: undefined: capnp.StructList
../books/books.capnp.go:90:15: undefined: capnp.StructList
../books/books.capnp.go:97:21: f.Future.Ptr undefined (type *capnp.Future has no field or method Ptr)
test@9cea4defcf09:~/go-capnp/example/books/ex1$ go version
go version go1.22.0 linux/amd64
test@9cea4defcf09:~/go-capnp/example/books/ex1$ 

Fixed with: go install capnproto.org/go/capnp/v3/capnpc-go@v3.0.0-alpha.1

Seems very likely to work with the next release, I'm closing this ticket.