下载后是否可以在模块中生成代码?

发布于 2025-02-12 23:29:32 字数 560 浏览 0 评论 0原文

如标题所述,是否可以生成代码(使用// 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羞稚 2025-02-19 23:29:32

没有明显的安全原因,这是不可能的。

No this is not possible for obvious security reasons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文