下载后是否可以在模块中生成代码?
如标题所述,是否可以生成代码(使用// og go:generate
之类的内容)下载模块依赖性?
具体来说,假设有一个repo example.com/protobuf
包含一些.proto
文件和一些.sh
脚本,以生成不同语言的绑定。 ,加上go.mod
,因此可以用作类似的依赖性:
module example.com/application
go 1.18
require (
example.com/protobuf v1.0.0
)
但是,生成的.go
文件不包含在此回购中,它们必须是使用.sh
脚本之一生成,因此,如果尝试此操作,则会发现一个错误,例如module example.com/protobuf@latest找到(v1.0.0),但不包含软件包example.com/protobuf/foo
是否可以解决此问题,而无需求助于EG。 git子模型?
As the title says, is it possible to generate code (with something like //go:generate
) after a module dependency is downloaded?
Specifically, let's say there's a repo example.com/protobuf
containing some .proto
files and a few .sh
scripts for generating bindings in different languages, plus a go.mod
so it can be used as a dependency from go like so:
module example.com/application
go 1.18
require (
example.com/protobuf v1.0.0
)
However, the generated .go
files are not included in this repo, they have to be generated using one of the .sh
scripts, so if you try this, you get an error like module example.com/protobuf@latest found (v1.0.0), but does not contain package example.com/protobuf/foo
Is there a way around this without resorting to eg. git submodules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有明显的安全原因,这是不可能的。
No this is not possible for obvious security reasons.