generate go files based on protobuf via import

1.2k views Asked by At

I have two git repositories:

common this repository contains protobuf files (.proto), these files should be fetched via git submodule init from other vendor repository. There are also go files with directive: //go:generate protoc --proto_path=a/xxx --go_out=. --go_opt=paths=source_relative a/xxx/b.proto

main this repository contains main project, which imports the package from common. Then I call git submodule update --init and the go generate. After generate i can see the log: go: finding github.xxx.com/xxx latest

but the main go file shows some problems: build github.xxx.com/main: cannot load github.xxx.com/xxx/proto: module github.xxx.com/common@latest found, but does not contains package github.xxx.com/xxx/proto

It seems that the go generate command doesn't generate proto files. I think if I import something then these files are somewhere in cache. I'm not sure if my approach is possible.

Could you tell me if this solution is feasible or what I should change.

1

There are 1 answers

0
user3930618 On

ok, my solution is project layout like this: https://github.com/golang-standards/project-layout

there I have more main.go files inside cmd folder. In this way I have only one module and inside the module I can have different applicaions. I think it's very cool solution.