Question

Shared library in Go?

Is it possible to create a Shared Library (.so) using Go?

UPDATED: created an "issue" for it.

 45  52784  45
1 Jan 1970

Solution

 54

This is possible now using -linkshared flag

What you need to do is to first run this command:

go install -buildmode=shared -linkshared  std

(Above code makes all common packages shareable!) then

go install  -buildmode=shared -linkshared userownpackage

finally when compiling your code you need to run:

go build -linkshared yourprogram

What the above those is now it rather than statically linking everything only dynamically links them and you will end up with much smaller compiled files. Just to give you an idea my "hello.go" file with static linking is 2.3MB while the same code using dynamic linking is just 12KB!

2016-01-28