How to build multiple package binaries at once
<p>I've seen this discussed in various places, with answers like 'use a cmd/foo, cmd/bar' type folder structure.</p>

<p>This does not work for me. </p>

<p>This works:</p>

<pre><code>$ du -a
8   ./src/cmd/bin1/main.go
8   ./src/cmd/bin1
8   ./src/cmd/bin2/main.go
8   ./src/cmd/bin2
16  ./src/cmd
8   ./src/shared/foo/foo.go
8   ./src/shared/foo
8   ./src/shared
24  ./src
</code></pre>

<p>and building it:</p>

<pre><code>go build ./src/cmd/bin2
go build ./src/cmd/bin1
</code></pre>

<p>However, I can't figure out what variation on:</p>

<pre><code>go build ./src/...
</code></pre>

<p>I might need to build all such binaries in one step.</p>

<p>This layout:</p>

<pre><code>$ du -a
8   ./cmd/bin1/main.go
8   ./cmd/bin1
8   ./cmd/bin2/main.go
8   ./cmd/bin2
16  ./cmd
8   ./src/shared/foo/foo.go
8   ./src/shared/foo
8   ./src/shared
8   ./src
24  .
</code></pre>

<p>Seems totally unusable. No combination of <code>go build ...</code> commands seems to build bin1 or bin2. </p>

<p>The best I can get is <code>go build cmd/bin1/main.go</code> which gives me a binary called 'main'. Not helpful.</p>

<p>So, specifically and in detail, including the <code>go build</code> command, that actually builds the individual binaries, how do you do this?</p>

<p>...and why is the default advice that people keep giving to use a top level <code>cmd</code> folder? How do you build these binaries if you do?</p>