dongyilai4214 2019-03-31 08:00
浏览 402
已采纳

如何使用Maven构建GO可执行文件

I have my Go source code, after go build, an executable is generated, which accepts some parameters to produce the output. Is there any way build the executable from maven build with any plugins?

  • 写回答

2条回答 默认 最新

  • dongzha3058 2019-04-01 12:59
    关注

    You can just put your go build command into a shell script and run it with this plugin:

    <plugin>
      <artifactId>exec-maven-plugin</artifactId>
      <groupId>org.codehaus.mojo</groupId>
      <executions>
        <execution>
          <id>Build Go binary</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>exec</goal>
          </goals>
          <configuration>
            <executable>${basedir}/build-golang-app.sh</executable>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    Other option is this Golang plugin which is more feature-rich and specific to this problem. However for simple use cases I would still go with Shell script.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记