如何在Go中包含来自第三方程序包的标头?

Let's supose my package workspace has github.com/yada/yada third party package. Inside this package there is a yoda.go.h header I would like to reuse (not sure if it's a good idea, but that's a hole new question). How do I import the header from a dependecy package into my own package?

package main

// #cgo pkg-config: my-dep other-dep
// #include <someHeader.h>
// #include <otherHeader.h>
// #include github.com/yada/yada/yoda.go.h // doesn't work :(
import "C"

Apart from being a good idea or not, I still would like to know if it's possible.

PS: If you think it's really a bad idea, what should I do instead?

Use CGO CFLAGS directive to reference additional include path.

//#cgo CFLAGS: -I $GOPATH/src/github.com/yada/yada/
...
//#include "yoda.go.h"
import "C"

CORRECTION:

The go tool does not expand $GOPATH variable during build. Instead, the full path should be used there. Corrected code:

//#cgo CFLAGS: -I /full/path/to/src/github.com/yada/yada/
//#include "yoda.go.h"

Probably not a good idea to try and reference it directly, since it's not an exported entity, and is subject to change or removal.

If you really need that header, you'll have to reference it directly in your local filesystem. (of course you're free to copy into your project too)