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

如何使用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 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死