dtb81443 2015-09-13 03:20
浏览 3

源代码结构:部署带有子包的Go

When there is just one go repository and it imports only public dependencies, deploying to (for example, a Docker container on AWS) is extremely straightforward.

However, I have a question about how to use subpackages with go.

Suppose we have a monorepo with 3 packages.

/src
- /appA
- /appB
- /someSharedDep

How are deployments typically built so that you deploy appA and someSharedDep to one server and appB and someSharedDep on another server?

I imagine there needs to be some creative employments of our friend the GOPATH, but some help on the topic would be appreciated.

Bonus points if we're talking about an elastic beanstalk deployment.

Suspicions

I have some thoughts on how to approach the problem now (and I'll add more or submit an answer if this becomes more complete).

  1. Use vendoring, this means you have the source code of all your dependencies checked into your own repo. It doesn't sound good (esp. if you're used to NodeJS) but it works.
  2. Now that you use vendoring, vendor your own submodules into the ./vendor folder in the application. Yes you will have copies of the same code in two places but whatever.
  3. Create automated scripts to help manage some of these things. I'm still looking for tools that make vendoring more convenient.

Some problems I still face:

  1. When vendoring, sometimes the dependency has files that have a main() function or declare package main, usually in an ./example subfolder. These have to be removed manually. I don't like editing the working source of someone else's project though!
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 制裁名单20240508芯片厂商
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致