marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
714 stars 106 forks source link

possible to compile from source and link the json or other extension statically? #104

Closed beswarm closed 1 year ago

beswarm commented 1 year ago

Thanks for the golang binding for duckdb. I have a question related to build the duckdb from source and include the json plugin, so that when I run it docker container, it do not need download the extension from internet.

originally, I use the below line to statically build , it success, RUN CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static" -w -s' -o app ./cmd

but when run it in docker container, and use json plugin, it will try to download the json extension into the ~/.duckdb directory. it will takes a long time to download , also, it does not work.

so is it possible to link statically the json plugin? in the duckdb cmake file, it does have the following options, I just do not know how to pass it to customize duckdb build using cgo and link the plugin statically? Is this possible?

option(BUILD_JSON_EXTENSION "Build the JSON extension." FALSE) option(EXTENSION_STATIC_BUILD "Extension build linking statically with DuckDB. Required for building linux loadable extensions." FALSE)

beswarm commented 1 year ago

It seems impossible to do this, the source code is not inside libduckdb-src.zip file