Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: make it possible to know the go initialization in shared libraries is finished without calling a go function #11768
Please see golang-nuts › How to export C variables from Go shared libraries? for discussion.
I tried to write a Go shared library to make Apache or nginx modules.
#2. What operating system and processor architecture are you using?
Ubuntu Linux trusty amd64
#3. What did you do?
Open a Go shared library written from a C main program. Please refer to the commit https://github.com/hnakamur/export_c_variable_from_go_dll_experiment/tree/0972d57461b091aed35c9ed083af0edae0c885cc for source codes.
With these source codes above, I ran
I expect to see
When I added
Please refer to the commit https://github.com/hnakamur/export_c_variable_from_go_dll_experiment/tree/1951dfb411dcff8986687ca98f801505397fc6cf for source codes.
I would like to know when the Go initialization of shared libraries is finished without calling a Go function.
Ideally, I would like to set values of C variables at Go shared library compile time, instead of updating values of C variables with
changed the title
Make it possible to know the go initialization in shared libraries is finished without calling a go function
Jul 18, 2015
This is -buildmode=c-shared, so we are writing a library that can operate as a plugin for an existing program. That program doesn't know that it needs to call a function. It doesn't know that the plugin is written in Go. The program thinks that after it loads the library it can freely refer to variables defined by the plugin.