How to use Go to build shared libraries
Go Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
gofromgo Fixing code samples. Aug 27, 2015
gofrompython Updated ctags docs to use c-string Aug 18, 2015
.gitignore Updated instructions. Aug 14, 2015 Create Aug 18, 2015
LICENSE Create LICENSE Aug 14, 2015 More small fixes. Aug 19, 2015

Using Go Shared Libraries

This project demonstrates a few new features that were added or improved in the Go 1.5 release:

  • -buildmode=shared - The ability to create a .so file from a Go package that can be called by other Go programs.
  • -linkshared - The ability to compile and link a Go program aginst previously compiled shared libraries.
  • -buildmode=c-shared - The ability to create a c-style .so file from a Go package that can be called by other languages.

This work is based on the Execmodes proposal found here. Keep in mind that this has only been tested on Linux. Certain features are not yet available on all Go platforms.

To get started, you'll need a working Go 1.5 installation. If you haven't already upgraded, follow the [download and install instructions here] (

To use these examples locally, I suggest you clone this repo:

$ mkdir buildmodeshared
$ git clone buildmodeshared

Once you have the repo cloned, see the gofromgo and gofrompython directories for next steps.

  • Go from Go - The ability to compile a Go program that is dynamically linked to other Go libraries.
  • Go from Python - The ability to compile a set of Go packages into a C-style shared library that can be invoked from other languages, such as Pyhon.


For details, see CONTRIBUTING.


For details, see LICENSE.


This is not an official Google project.