#cgo-exmaple
There are five examples of using cgo.
C code is built in Go program.
usage: cd builtin && go build && ./builtin
Using C static library in Go program.
The function add
was written in C and built in static library: add.a
.
usage: cd c-lib && make && ./c-lib
Using C shared library in Go program.
The function add
was written in C and built in shared library: add.so
.
usage: cd c-so && make && ./c-so
Calling Go function in C program.
The function add
was written in Go and built in static library.
Then called by main.c
.
usage: cd go-lib && make && ./go-lib
Calling go function in c program.
The function add
was written in Go and built in shared library.
Then called by main.c
.
usage: cd go-so && make && ./go-so