Open herugen opened 3 years ago
I can't reproduce this running with libprotoc 3.14.0
and go version go1.15.6 linux/amd64
.
I have the same problem.
libprotoc 3.14.0
go version go1.15.8 linux/amd64
# github.com/googleapis/gnostic/metrics/vocabulary
metrics/vocabulary/vocabulary.go:71:29: cannot use v (type *gnostic_metrics_v1.Vocabulary) as type protoreflect.ProtoMessage in argument to "google.golang.org/protobuf/proto".Marshal:
*gnostic_metrics_v1.Vocabulary does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
metrics/vocabulary/vocabulary.go:86:29: cannot use v (type *gnostic_metrics_v1.VocabularyList) as type protoreflect.ProtoMessage in argument to "google.golang.org/protobuf/proto".Marshal:
*gnostic_metrics_v1.VocabularyList does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
metrics/vocabulary/vocabulary.go:101:29: cannot use v (type *gnostic_metrics_v1.VersionHistory) as type protoreflect.ProtoMessage in argument to "google.golang.org/protobuf/proto".Marshal:
*gnostic_metrics_v1.VersionHistory does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
metrics/vocabulary/vocabulary.go:212:23: cannot use v (type *gnostic_metrics_v1.Vocabulary) as type protoreflect.ProtoMessage in argument to "google.golang.org/protobuf/proto".Unmarshal:
*gnostic_metrics_v1.Vocabulary does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
make: *** [Makefile:4: all] Error 2
I see the same issue with
go version go1.16 darwin/amd64
libprotoc 3.15.3
I am also seeing a compile error:
libprotoc 3.6.1 (I also tried libprotoc 3.15.5) go version go1.16.2 linux/amd64
root@56cc44da8415:/go/src/github.com/google/gnostic# make
go generate ./...
go get: upgraded github.com/golang/protobuf v1.4.3 => v1.5.1
go get: upgraded google.golang.org/protobuf v1.24.0 => v1.26.0
protoc-gen-go: invalid Go import path "openapiv2" for "openapiv2/OpenAPIv2.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "openapiv3" for "openapiv3/OpenAPIv3.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "discovery" for "discovery/discovery.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "plugins" for "plugins/plugin.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "extensions" for "extensions/extension.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "surface" for "surface/surface.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "metrics" for "metrics/vocabulary.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
protoc-gen-go: invalid Go import path "metrics" for "metrics/complexity.proto"
The import path must contain at least one forward slash ('/') character.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
--go_out: protoc-gen-go: Plugin failed with status code 1.
gnostic.go:15: running "./COMPILE-PROTOS.sh": exit status 1
make: *** [Makefile:3: all] Error 1
root@56cc44da8415:/go/src/github.com/google/gnostic#
I'm having the same issue as the guy above me. After digging around a bit, it seems to be caused by this change: https://github.com/protocolbuffers/protobuf-go/commit/8b366e880709d9be636fad37fdab80990e7effc9#diff-399aacc23da934164976b6fb41cbb5cff5df743f45210d007800504022127b86
Should I open a separate issue?
After running make
I also got the same error as @qas
Environment go version go1.16.3 darwin/amd64 libprotoc 3.15.8
Ok I think I figured out the problem, thanks to @Adarah for pointing me to the commit.
When protogen.go
is run, it executes impPath, pkgName := splitImportPathAndPackageName(value)
which splits the go_package variable in the .proto
file. The problem is that the Go import path is expected to contain a forward slash. To fix this, every instance of go_package
should be modified in the following way
// The Go package name.
option go_package = "openapiv3;openapi_v3";
to
// The Go package name.
option go_package = "openapiv3/;openapi_v3";
for the following files
After making these changes and running make
, I got that there was a similar error for gnostic/extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.proto
So I made the following change in that file from
// The Go package path.
option go_package = ".;sampleone";
to
// The Go package path.
option go_package = "./;sampleone";
Then when I did that and ran make
again I got the following error:
go generate ./...
go get ./...
# github.com/googleapis/gnostic/extensions/sample/generated/gnostic-x-sampleone/proto
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:33:58: undefined: Book
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:35:8: undefined: Book
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:81:59: undefined: Shelf
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:83:8: undefined: Shelf
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:129:10: undefined: Book
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:135:10: undefined: Shelf
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:141:10: undefined: Book
extensions/sample/generated/gnostic-x-sampleone/proto/x-sampleone.go:156:10: undefined: Shelf
make: *** [all] Error 2
There seems to be a problem when generating this sample .proto file where the go_package path is written improperly. I have very limited experience with go but from a brief browse of the source code my guess is that it has something to do with writing the package path.
Ok I think the problem is here:
and here:
The following code for the ProtoOption
should be changed from
ProtoOption{
Name: "go_package",
Value: directoryName + ";" + packageName, // <-- this line here
Comment: "// The Go package name.",
},
to
ProtoOption{
Name: "go_package",
Value: directoryName + "/;" + packageName, // <-- this line here
Comment: "// The Go package name.",
},
or an equivalent change should be made to ensure that the directoryName
variable has a trailing /
.
To conclude, make
runs without errors if I
generate-gnostic*
in my ~/go/bin
path.proto
files listed in my comment above andProtoOption
to include a trailing slash after directoryName
Environment: go version go1.13 linux/amd64 libprotoc 3.14.0
Here follows my operation step:
And then errors happened: