开发者

How do I call C from Go using the "foreign function interface"

How do I use Go's "foreign function interface" to call out to a C function?

This interface is mentioned on 开发者_运维问答the FAQ, but I cannot see it mentioned elsewhere in the docs.


Check out this file from the Go repository. It shows how to wrap a C library in Go and has quite a few comments that explain the process.


Here is an article that demonstrates the following with Cgo:

To lead with an example, here's a Go package that provides two functions - Random and Seed - that wrap C's rand and srand functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜