golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.78k stars 1.58k forks source link

google.golang.org/protobuf(generate-protos): Go Workspace #1552

Open ldez opened 1 year ago

ldez commented 1 year ago

What version of protobuf and what language are you using? Version: all the version Go

What did you do?

I was working on a problem related to Go Workspace, and I detected a problem inside protobuf-go with Go Workspace.

The following lines, inside the command generate-protos, can't work inside a project that uses Go workspace:

https://github.com/protocolbuffers/protobuf-go/blob/fc47fdd3d3fca5283fa9428ac94cf730236e4ca3/internal/cmd/generate-protos/main.go#L36-L40

Inside a Go workspace, the command go list -m returns all the modules inside the workspace.

As an example of the behavior, you can create a workspace by following this official tutorial.

At any location (at the root of the workspace or inside a module), the command will have this behavior:

$ go list -m -f "{{.Path}}"
golang.org/x/example
example.com/hello
$ cd hello
$ go list -m -f "{{.Path}}"
golang.org/x/example
example.com/hello

What did you expect to see?

I'm not sure how to test this command, I don't find any usage example of this command, if you need I can run it but I will have to ask for an example.

What did you see instead?

I'm not sure how to test this command, I don't find any usage example of this command, if you need I can run it but I will have to ask for an example.

Anything else we should know about your project / environment?

hoeppi-google commented 1 year ago

generate-protos predates workspaces. It is not meant to be run directly. It is only meant to be run via regenerate.bash/test.bash by people working on the module.

We will look at a fix if someone wants to contribute one.