How to test "main()" routine from "go test"?
<p>I want to lock the user-facing command line API of my <em>golang</em> program by writing few anti-regression tests that would focus on testing my binary as a whole. What testing "binary as a whole" means is that go-test should:</p>

<ol>
<li>be able to feed STDIN to my binary</li>
<li>be able to check that my binary produces correct STDOUT</li>
<li>be able to ensure that error cases are handled properly by binary</li>
</ol>

<p><strong>However, it is not obvious to me what is the best practice to do that in <em>go</em>? If there is a good <em>go</em> test example, could you point me to it?</strong></p>

<p>P.S. in the past I have been using <em>autotools</em>. And I am looking for something similar to AT_CHECK, for example:</p>

<pre><code>AT_CHECK([echo "XXX" | my_binary -e arg1 -f arg2], [1], [],
  [-f and -e can't be used together])
</code></pre>