TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Build Golang projects properly with Makefiles

2 pointsby ahacker15over 8 years ago

2 comments

dozzieover 8 years ago
<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 未加载
Annatarover 8 years ago
<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.