Closed solarhell closed 1 week ago
Hello, thanks for filing this issue. This is occurring because we added cpp_features.proto and java_features.proto files which do not have the go package
option defined.
That being said, if you are looking to work with well-known types and Go code, they are available already in the Go protobuf runtime: https://pkg.go.dev/google.golang.org/protobuf/types/known@v1.35.1.
I also noted that you are attempting to generate this with connect-go
-- there are no RPC services for well-known types, which is what the connect-go
plugin is used to generate, so you should not be using the plugin with the well-known type protobuf definitions.
Thanks for the reply, I am indeed using connect-go
and have added googleapis
and wellknowntypes
to the deps
of buf.yaml
. What should I tweak to avoid generating code for wellknowntypes?
FYI,this my is my current config
buf.yaml
version: v2
modules:
- path: .
name: buf.build/wolodata/api
lint:
use:
- STANDARD
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
deps:
- buf.build/googleapis/googleapis
- buf.build/protocolbuffers/wellknowntypes
and buf.gen.yaml
version: v2
managed:
enabled: true
override:
- file_option: go_package_prefix
value: github.com/wolodata/proto/gen
plugins:
- remote: buf.build/protocolbuffers/go:v1.35.1
out: gen
opt:
- paths=source_relative
- remote: buf.build/connectrpc/go:v1.17.0
out: gen
opt:
- paths=source_relative
- remote: buf.build/connectrpc/es:v1.5.0
out: gen
- remote: buf.build/bufbuild/es:v1.10.0
out: gen
Ah okay, I see, thank you for providing this context! So if you are using the well-known types as a part of your proto definitions, you don't actually need to provide the buf.build/protocolbuffers/wellknowntypes
module, you get them for free as part of the compilation. There is a small quote in the well-known types module documentation on this:
Even without depending on this module, you can use these files out of the box.
So unless you have a special use-case (as outlined in the README), you can simply remove that from your deps. Let me know if this helps! That being said, we are also still looking into the issue with the Go module internally.
Thanks for you reply.
I tried removing buf.build/protocolbuffers/wellknowntypes
from the deps
of buf.yaml
, and when I run buf lint
, the warning suggests that
WARN File "permission/v1/permission.proto" imports "google/protobuf/descriptor.proto", which is not in your workspace or in the dependencies declared in your buf.yaml, but is found in transitive dependency "buf.build/protocolbuffers/wellknowntypes".
Declare "buf.build/protocolbuffers/wellknowntypes" in the deps key in your buf.yaml.
WARN File "article/v1/article.proto" imports "google/protobuf/wrappers.proto", which is not in your workspace or in the dependencies declared in your buf.yaml, but is found in transitive dependency "buf.build/protocolbuffers/wellknowntypes".
Declare "buf.build/protocolbuffers/wellknowntypes" in the deps key in your buf.yaml.
And the generated connect-rpc code still requires buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go
.
module buf.build/gen/go/wolodata/api/connectrpc/go
go 1.21
require (
buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go v1.17.0-20240829202630-d59b7d45e69d.1
buf.build/gen/go/wolodata/api/protocolbuffers/go v1.34.2-20241111085537-48f371483e91.2
connectrpc.com/connect v1.17.0
)
And check the code, i can see that the buf.build/gen/go/protocolbuffers/wellknowntypes/protocolbuffers/go
is not used.
So I did a little digging into your issue by checking your module on buf.build/wolodata/api
. Because you added the buf.build/protocolbuffers/wellknowntypes
dependency in the past, it is not being pruned from your buf.lock
, even though it is removed from your buf.yaml
.
In this case, the easiest solution will be to remove your buf.lock
entirely and then run buf dep update
with your new buf.yaml
without the dependency on buf.build/protocolbuffers/wellknowntypes
. This will pick up any updates to googleapis
, but you are already depending on the latest version. This will now remove your dependency entirely on the well-known types module, and should no longer pick this up in your generated code.
Let me know if this helps!
After removing buf.lock
and updated the deps, it works fine. Thank you for your generous help.
How to reproduce
https://sum.golang.org/lookup/buf.build/gen/go/protocolbuffers/wellknowntypes/connectrpc/go@v1.17.0-20240829202630-d59b7d45e69d.1
Output
Expected Output
something like this
https://sum.golang.org/lookup/golang.org/x/tools@v0.26.0
Anything else?
No response