Joe Tsai ce5d8318a0 compiler/protogen: avoid suggesting faulty go_package option
In some situations, the full Go package path cannot be determined,
in which case, we should avoid suggesting a go_package option
that is incorrect.

As a heuristic, check whether the proposed path contains at least
a dot before a slash to determine whether it is a full path or not,
which is a simple way to determine whether the first segment is a
top-level domain.

This avoids printing unhelpful warnings like:
	WARNING: Missing 'go_package' option in "foo/bar.proto", please specify:
		option go_package = ".;foo_package";
	A future release of protoc-gen-go will require this be specified.
	See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.
and instead prints a warning like:
	WARNING: Missing 'go_package' option in "foo/bar.proto",
	please specify it with the full Go package path as
	a future release of protoc-gen-go will require this be specified.
	See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

We rely on the documentation on the developer website to provide
better guidance.

Change-Id: I38fc4c676d0314ba6d7ad8d5f390fb9e237f2bb1
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/232338
Reviewed-by: Damien Neil <dneil@google.com>
2020-05-05 20:53:59 +00:00
..