GoDynamic can load and run Golang dynamic library compiled by -buildmode=shared -linkshared
GoDynamic works like a dynamic linker: use dl loads an .so libraray and lookup symbol, can unload.
Please note that GoDynamic is not a scripting engine. All features of Go are supported, and run just as fast and lightweight as native Go code.
GoDynamic reuses runtime by libstd.so, which makes it much smaller. And code loaded by GoDynamic is unloadable.
Make sure you're using go >= 1.10.
export GO111MODULE=auto
go install -buildmode=shared std
go build -linkshared -v github.com/pkujhd/godynamic/examples/loader
go install -v -buildmode=shared -linkshared github.com/pkujhd/godynamic/examples/ubase
./loader -l $GOPATH/pkg/linux_`go env GOARCH`_dynlink/libgithub.com-pkujhd-godynamic-examples-ubase.so -p github.com/pkujhd/godynamic/examples/ubase.so -r github.com/pkujhd/godynamic/examples/ubase.Enter -times 10
go install -v -buildmode=shared -linkshared github.com/pkujhd/godynamic/examples/uschedule
./loader -l $GOPATH/pkg/linux_`go env GOARCH`_dynlink/libgithub.com-pkujhd-godynamic-examples-uschedule.so -p github.com/pkujhd/godynamic/examples/uschedule.so -r github.com/pkujhd/godynamic/examples/uschedule.Enter -times 10
go install -v -buildmode=shared -linkshared github.com/pkujhd/godynamic/examples/uhttp
./loader -l $GOPATH/pkg/linux_`go env GOARCH`_dynlink/libgithub.com-pkujhd-godynamic-examples-uhttp.so -p github.com/pkujhd/godynamic/examples/uhttp.so -r github.com/pkujhd/godynamic/examples/uhttp.Enter
This has currently only been tested and developed on: Golang 1.10-1.19 (x64/x86, linux)