title: cgo doesn't export functions in imported packages
body: <p>I'm trying to build existed Go package into C shared library and header using <a href="https://golang.org/cmd/cgo/" rel="nofollow noreferrer">CGO</a>.</p>
  
  <p>I built the package with <code>-buildmode c-shared</code> as documented.</p>
  
  <pre><code>-buildmode=c-shared
      Build the listed main package, plus all packages it imports,
      into a C shared library. The only callable symbols will
      be those functions exported using a cgo //export comment.
      Requires exactly one main package to be listed
  </code></pre>
  
  <p>And used <code>//export Func</code> to expose functions as C symbols.</p>
  
  <p>All <code>//export</code> functions in <code>main</code> package are exported properly. However when I moved those functions to sub-package (with <code>//export</code>), those functions are not exported. I imported the sub-package in <code>main</code> package, too.</p>
  
  <p>Here's my code.</p>
  
  <p><em>main.go</em></p>
  
  <pre><code>package main
  
  import "C"
  
  import (
      "fmt"
      _ "github.com/onosolutions/archanan-cgo/c"
      "math/rand"
  )
  
  // FuncInMain generates a random integer.
  //export FuncInMain
  func FuncInMain(max C.int) C.int {
      return C.int(rand.Intn(int(max)))
  }
  
  func main() {
      fmt.Printf("Hello World %d!\n", int(FuncInMain(256)))
  }
  </code></pre>
  
  <p><em>c/c.go</em></p>
  
  <pre><code>package c
  
  import "C"
  
  import (
      "math/rand"
  )
  
  // FuncInSubPackage generates a random integer.
  //export FuncInSubPackage
  func FuncInSubPackage(max C.int) C.int {
      return C.int(rand.Intn(int(max)))
  }
  </code></pre>
  
  <p>Then only <code>FuncInMain</code> is exported.</p>
  
  <p>I read through <a href="https://golang.org/cmd/cgo/" rel="nofollow noreferrer">CGO documentation</a>, but there's nothing saying about exporting in sub-packages. The only clue I got is through <code>go help buildmode</code>, but it said that all imported sub-packages will be compiled. I'm not sure whether it isn't supported or I missed some configurations.</p>
  
  <p>I'd love to achieve that to be able to modularize <code>//export</code> functions.</p>