title: Compiling go library without GCO to run on alpine, error in libczmq
body: <p>When trying to run my binary on <code>alpine</code>, I got the error:</p>
  
  <pre><code>... binary not found
  </code></pre>
  
  <p>which typically happens when there's a problem with architecture, or as I found, <code>glibc</code>. I searched and discovered that <code>alpine</code> instead uses <code>muslc</code>, an alternative <code>C</code> library. I then found this <a href="https://stackoverflow.com/questions/34729748/installed-go-binary-not-found-in-path-on-alpine-linux-docker">Installed Go binary not found in path on Alpine Linux Docker</a> that teaches how to compile without <a href="https://golang.org/cmd/cgo/" rel="nofollow noreferrer"><code>CGO</code></a>, which is the thing that permits loading <code>C</code> libraries from go:</p>
  
  <pre><code>GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o [name of binary]
  </code></pre>
  
  <p>When I run this, I get:</p>
  
  <pre><code>go build gopkg.in/zeromq/goczmq.v4: no buildable Go source files in /home/lucas/Go/src/gopkg.in/zeromq/goczmq.v4
  </code></pre>
  
  <p>I suspect that it's because <code>libczmq</code> is just a wrapper for the <code>C</code> written <code>libzmq</code>. In this case, how do I compile in a way that I can use <code>libczmq</code>? Why exactly <code>CGO</code> must be disabled in alpine?</p>
  
  <p>What's exactly <code>CGO</code>? Shouldn't it use <code>libc</code> when available but <code>muslc</code> when not? I'd like to know more about what's happening in the background.</p>
  
  <p>Note: I'm compiling outside alpine, in ubuntu, is that a problem? </p>