Developing Go shared libraries

Answered

Struggling a little but on this one - i am sure there is an easy answer but....

I am trying to build, in GoLand, several shared libraries that can be used across projects - both the application and library are Go.

I updated the Go tool arguments -buildmode=shared but than get the following error:

   GOROOT=/snap/go/9952 #gosetup
   GOPATH=/home/roger/go #gosetup
   /snap/go/9952/bin/go build -buildmode=shared -o /tmp/GoLand/___5go_build_kafkaLibrary -gcflags all=-N -l kafkaLibrary #gosetup
   -buildmode=shared and -o not supported together

   Compilation finished with exit code 1

is there a tutorial for setting up GoLand for developing shared libraries? Any help you can provide would be greatly appreciated.

0
12 comments

I faced similar kind of issue last time, I am still searching for some proper solution Same issue still no fix to this.

1

Interesting, this seems like something that should be fundamental functionality. Unfortunately this is critical for our projects...

0

Hello,

Do you want to compile that library, but not run it?

If so, you can consider Shell Script configuration instead and specify a custom go build command.

0

Ultimate goal is to run and debug the shared library when running in the system - the value of the IDE... really don't want to go back to sysout debugging.

0

Can you share some examples of shared libraries? Probably, it needs a reliable way to build and run them, it is not supported at the moment, but we can probably implement it in the future.

0

yes, we are looking at several product lines where we have a common set of building block components will need to be supported (based on our customer requirements): Kafka/ActiveMQ, Relational/NoSQL connectors and a list of proprietary addon's to the base platform.

Today more concerned with the system-addons that will be downloadable based on licensing. Kafka and reporting is in the base platform but will eventually need to also be embedded in libraries.

0

most additional details cannot be in a public forum.

0

I mean, is it crucial for your projects to use -buildmode=shared flag? As far as I can see, it has very specific use cases (and it is not compatible with Go modules entirely) and some use it to reduce binary size.

0

it is critical for us to use shared libraries - code size not withstanding. the question is how to efficiently do this in Goland. as it stands the only way this is possible is to script outside GoLand, which an assumption is i loose the nice debugging i get with the ide. (Assumption: I am back to a nice Notepad and sysout debugging - at least for today) - is this a reasonable assumption.

really do want to standardize on a single IDE across all development.

0

and if not today, are there thoughts around implementing this in a future release?

0

as it stands the only way this is possible is to script outside GoLand, which an assumption is i loose the nice debugging i get with the ide. (Assumption: I am back to a nice Notepad and sysout debugging - at least for today) - is this a reasonable assumption.

Have you considered Go Remote debugger feature? You can build an application on your own, then run it and attach a debugger: https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#attach-to-a-process-on-a-local-machine

0

i will try that, thank you

0

Please sign in to leave a comment.