title: Static golang build of app using cgo library
body: <p>I've decided to use zstd library for compression in my code using the <a href="https://github.com/DataDog/zstd" rel="nofollow noreferrer">Go wrapper from datadog</a>.<br>
  My build command for app is (I build my app in gitlab-ci using <code>image: golang:1.10.2-alpine</code>)</p>
  
  <pre><code>dep ensure --vendor-only
  CGO_ENABLE=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' cmd/main.go
  </code></pre>
  
  <p>Which fails with </p>
  
  <pre><code>build constraints exclude all Go files in /go/src/xxxxx/xxxx/xxxx/vendor/github.com/DataDog/zstd
  </code></pre>
  
  <p>When I try to enable <code>CGO_ENABLED</code> (and keep the rest of the build commands unchanged) I end up with warnings:</p>
  
  <pre><code># command-line-arguments
  /tmp/go-link-395607750/000054.o: In function `mygetgrouplist':
  /usr/local/go/src/os/user/getgrouplist_unix.go:15: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /tmp/go-link-395607750/000053.o: In function `mygetgrgid_r':
  /usr/local/go/src/os/user/cgo_lookup_unix.go:38: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /tmp/go-link-395607750/000053.o: In function `mygetgrnam_r':
  /usr/local/go/src/os/user/cgo_lookup_unix.go:43: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /tmp/go-link-395607750/000053.o: In function `mygetpwnam_r':
  /usr/local/go/src/os/user/cgo_lookup_unix.go:33: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /tmp/go-link-395607750/000053.o: In function `mygetpwuid_r':
  /usr/local/go/src/os/user/cgo_lookup_unix.go:28: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  /tmp/go-link-395607750/000004.o: In function `_cgo_f7895c2c5a3a_C2func_getaddrinfo':
  /tmp/go-build/cgo-gcc-prolog:46: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  </code></pre>
  
  <p>Which doesn't seem ok as I want to have my build statically linked. Do I have to firstly build zstd library and then build my app?</p>