Tutorial by Examples

Cgo enables the creation of Go packages that call C code. To use cgo write normal Go code that imports a pseudo-package "C". The Go code can then refer to types such as C.int, or functions such as C.Add. The import of "C" is immediately preceded by a comment, that comment, call...
Calling C code from Go package main /* // Everything in comments above the import "C" is C code and will be compiles with the GCC. // Make sure you have a GCC installed. int addInC(int a, int b) { return a + b; } */ import "C" import "fmt" func ma...

Page 1 of 1