title: CGo tests with a DLL
body: <p>I'm currently using CGO to use a library in C through a DLL.
  Everything works and I can use my code on top of the library, build it &amp; so on.</p>
  <p>The problem I have is to implement tests with a DLL. Right now my project looks like:</p>
  <ul>
  <li>project
  <ul>
  <li>apis/
  <ul>
  <li>probes.go</li>
  <li>probes_test.go &lt;- uses Struct containing C defs</li>
  </ul>
  </li>
  <li>lib/
  <ul>
  <li>binding.go &lt;- defines CGO binding</li>
  </ul>
  </li>
  <li>main.go</li>
  <li>myLib.dll</li>
  </ul>
  </li>
  </ul>
  <p>So my lib folder got all CGO binding and a Go struct on top of it (as a wrapper kind of). And the probes are using this wrapper to expose some infos.</p>
  <p>The problem with doing <code>go test</code> is that the execution context is set within the package. Meaning probes_test.go executes in apis/ context and doesn't see the DLL. Making the test fail with a special exit status.</p>
  <p>The workaround is to replicate for now the dll in the package like:</p>
  <ul>
  <li>project
  <ul>
  <li>apis/
  <ul>
  <li>probes.go</li>
  <li>probes_test.go</li>
  <li>myLib.dll &lt;- replicated</li>
  </ul>
  </li>
  <li>lib/
  <ul>
  <li>binding.go</li>
  </ul>
  </li>
  <li>main.go</li>
  <li>myLib.dll</li>
  </ul>
  </li>
  </ul>
  <p>And this works (the test passes) but is hacky and not clean. I also tried to put the DLL only in lib/ but isn't working neither.</p>
  <p>Do you have a way of specifying for test that the DLL is in an other folder ?</p>