Newbie build configuration question

I have a plugin I build with something like the following in a shell file:

go build -ldflags "-pluginpath=plugins/rules/schedule-$(uuidgen)" -buildmode=plugin -o ../../../../plugins/rules/schedule.so main.go

Is there a way to make this work for a "go build" configuration setup? Either by filling out the fields in the configuration or just by having the configuration call the bash script.

My main concerns are that "uuidgen" will work (it's a Linux utility) and that I can change the name of the file from main to schedule.

I'm very new with Jetbrain tools so hopefully this isn't too dumb of a question.

Thanks!

0
2 comments
Official comment

Unfortunately, run configurations don't support shell commands. What I can suggest is to create a shell script and run it from the IDE instead of the Go run configuration. Would it work for you?

It's really no big deal as I keep several shell windows open for various things and it's perfectly fine to just run the shell script from a shell window - there's no special advantage to do it in an IDE. I asked more for just learning what I can and can't do in GoLand than anything else as I'm new to JetBrains IDEs in general.

I could see an advantage in an IDE if it had some advanced management. For example, if it knew that because of some update that the plugin code would become out of date to the main code and therefore automatically prompted you to rebuild the plugin(s) when necessary, that would be an advantage. Also below you can see that I have to build the plugin differently depending on whether I am running the main code in the IDE debugger or not. It would be nice to have the IDE automatically recompile the plugin(s) code to match how the main code was being run but, these are trivial things.

My only real concern about the IDE at the moment is it not showing global variables while debugging. I know where this came from, there was a bug in Delve for a while and you literally couldn't but that was fixed some time ago AFAIC remember and being such basic functionality for debugging shouldn't be missing at this point.

In case you want to consider expanding the functionality of the run configurations by making it possible to call a script or something here's what the script looks like at the moment.

#!/bin/sh

DEBUG=1

baseFileName='schedule'
srcFile="$baseFileName.go"
dstFile="$baseFileName.so"
dstFilePath="../../../../plugins/rules/$dstFile"

pluginPath="plugins/rules/$baseFileName"

if [ $DEBUG -eq 1 ]; then
# go build -gcflags "all=-N -l" -ldflags "-pluginpath=$pluginPath" -buildmode=plugin -o "$dstFilePath" "$srcFile"
go build -gcflags "all=-N -l" -ldflags "-pluginpath=$pluginPath-$(uuidgen)" -buildmode=plugin -o "$dstFilePath" "$srcFile"
else
# go build -ldflags "-pluginpath=$pluginPath" -buildmode=plugin -o "$dstFilePath" "$srcFile"
go build -ldflags "-pluginpath=$pluginPath-$(uuidgen)" -buildmode=plugin -o "$dstFilePath" "$srcFile"
fi
0

Please sign in to leave a comment.