Linking Go and C # Since Go 1.5, Go supports packaging Go codes into a shared or static library, which can be linked in C programs 1. package main // buildmode=[c-archive|c-shared] requires exactly one main package import "C" import "fmt" //export hello func hello(name string) { fmt.Printf("Hello from Go, %s!\n", name); } func main() {} ## as c-shared library go build -buildmode=c-shared -o libtest.so test.go ## as c-archive(static) library go build -buildmode=c-archive -o libtest.