Unfortunately the answer is that osquery doesn’t build as a library you can import in the way you’re expecting. It exposes an extensions interface using Thrift, and others have created an “SDK” for languages like Go
https://github.com/osquery/osquery-go wherein the Go developer can write an extension and easily bind to the extensions interface of the osquery agent.