douman6679 2017-08-27 16:41
浏览 49

如何在Heroku上运行go generate

I am using to embed static files and templates within Go executable file. It requires to run go generate to run a Go code that read each file and write binary representation as standard go file. go generate have to be fired before build process. Is there a chance to configure Heroku to handle this?

  • 写回答

1条回答 默认 最新

  • dongzhi2887 2017-08-27 16:47

    go generate should be run locally while developing, not on heroku. If you run it on heroku it will lead to very hard to debug issues. If go generate has unexpected results you wont be able to easily inspect this.

    You could run go generate with a tool like modd or with a git hook. Having the results of go generate tracked by git also means that you can track which changes affected generated code.

    In a language like ruby it might be customary to run bundle install on the server and omit dependencies from git. For go programs this is not so. Dependencies should be vendored and tracked by git. Same for generated code.

    The rest is not at all advised for this case and I would never do something like this.

    • fork the go heroku buildpack
    • add a line to run go generate
    • use your modified go heroku buildpack
    • deploy your app

    around this line

    more on buildpacks

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 我有个餐饮系统,用wampserver把环境配置好了,但是后端的网页却进去,是为什么?
  • ¥15 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"
  • ¥20 基于决策树的数字信号处理,2ask 2psk 2fsk的代码,检查下报错的原因
  • ¥20 python作业求过程
  • ¥15 wincc已组态的变量过多
  • ¥60 如图:直线与椭圆X轴平行,求直线与椭圆任意一点的相切坐标计算公式
  • ¥50 如何用python使用opencv里的cv::cudacodec::VideoWriter函数对视频进行GPU硬编码
  • ¥100 c#solidworks 二次开发 工程图自动标边线法兰 等折弯尺寸怎么标
  • ¥15 halcon DrawRegion 提示错误
  • ¥15 FastAPI Uvicorn启动显示404