作为构建过程的一部分运行命令行工具。

huangapple go评论86阅读模式
英文:

Run a command line tool as part of build process

问题

我刚刚开始学习Go语言,同时也想学习Sublime Text。

我已经安装了官方的Sublime的Go构建包,并且一切都很顺利。但是我的小项目依赖于二进制资源,所以我正在使用go-bindata将我的文件直接构建到可执行文件中。

我需要帮助的是,我不知道如何将go-bindata的命令行调用添加到Go构建提供的构建过程中。理想情况下,我希望在构建过程开始之前简单地运行该命令。

我正在使用Windows 10,如果这是重要信息的话。

谢谢!

英文:

I'm just getting started with Go, and also thought I'd learn Sublime Text while I was at it.

I've installed the official Go Build package for Sublime and got everything building nicely. But my little project relies on binary resources, so I'm using go-bindata to build my files directly into my executable.

What I need help with is the fact I don't know how to add the command line call to go-bindata to the build processes provided by Go Build. Ideally I'd like to simply run the command before the build process starts.

I'm working on Windows 10, if that's important info.

Cheers!

答案1

得分: 1

通常可以使用go generate来完成这个操作。尽管Sublime3捆绑包不支持这个功能。

在你的文件中,添加以下内容作为顶部注释:

//go:generate go-bindata data/

现在,你可以使用go generate来打包和构建你的项目,然后使用go build

这适用于所有Go支持的平台。

如果真的需要一个命令来完成所有的事情:可以使用一个Makefile或批处理脚本,并将其作为Sublime中的构建命令。

英文:

Usually this is done with go generate. Although the Sublime3 bundle does not support this.

In one of your files add something like this into as the top comment:

//go:generate go-bindata data/

Now you can bundle and bundle your project with go generate and then go build.

This works on all platforms that are supported by Go.

If really need a one command does everything thing: Use a Makefile or a batch script and use that as your build command in Sublime.

huangapple
  • 本文由 发表于 2017年3月21日 03:15:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/42912129.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定