TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Build Golang projects properly with Makefiles

2 点作者 ahacker15超过 8 年前

2 条评论

dozzie超过 8 年前
<p><pre><code> BUILD=`git rev-parse HEAD` LDFLAGS=-ldflags &quot;-X main.Version=${VERSION} -X main.Build=${BUILD}&quot; # ... $(BINARY): go build ${LDFLAGS} -o {$BINARY} .&#x2F;.. </code></pre> Please don&#x27;t do that. This ties the build process to be run from inside the git repository, which starts to be a problem if you have any sane method of code deployment (building source packages). Think of something different.<p>And yes, there is a typo in the build rules.
评论 #13130360 未加载
Annatar超过 8 年前
<p><pre><code> ${BINARY}: main.go go build $&lt; -o $@ </code></pre> this way, make will know to re-build the binary only if the source code has changed.