title: Using Go code in an existing C project
body: <p>Ever since Go 1.5 came out, I started taking another look at how I could integrate it into an existing project of mine.</p>
  
  <p>The project's codebase is written entirely in C for low level access to to hardware and other fun stuff. However, some of the higher level things are tedious, and I would like to start writing them in a higher level language (Go)</p>
  
  <p>Is there any way I can call Go code from a C program? I installed Go 1.5, which added <code>-buildmode=c-archive</code> (<a href="https://golang.org/s/execmodes">https://golang.org/s/execmodes</a>) which I am trying to get working.</p>
  
  <p>However, I can't seem to get Go to generate the appropriate header files to allow my project to actually compile. When I generate the archive, I see the function in the exported symbols (using objdump), but without the header files to include gcc complains about the function not existing (as expected)</p>
  
  <p>I'm quite new to Go - however, I love the language and would like to make use of it. Is there any idiomatic way ("idiomatic" gets used a lot in the world of Go I see...) to get this to play nicely with each other?</p>
  
  <p>The reason I asked this question and specifically mentioned Go 1.5 is that according to this document, <a href="https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGhFDelrAP0NqSS_00RgZQ/edit?pli=1#heading=h.1gw5ytjfcoke">https://docs.google.com/document/d/1nr-TQHw_er6GOQRsF6T43GGhFDelrAP0NqSS_00RgZQ/edit?pli=1#heading=h.1gw5ytjfcoke</a>
  Go 1.5 added support for non-Go programs to call Go code. Specifically, mentioned under the section "Go code linked into, and called from, a non-Go program"</p>