Dynamic Resolution of Protocol ID for 3rd Party API calls

We are attempting to port a Go application to the WP77 target. The use of custom compile tools (mkapp, etc.) complicates the use of cgo. To at least get something working I am leaning towards the approach shown in a prior thread. In this thread, the Go code is able to interact with a legato defined API once the Protocol ID is resolved (all other information can be gathered prior to runtime).

If I am trying to interact with a predefined service API (unlike the prior thread that defines a new printer API), how can I resolve the Protocol ID and Name at runtime?

maybe protocol ID can be found by the following:

root@swi-mdm9x28-wp:~# ls -l /mnt/flash/legato/systems/current/apps/ | grep hello
lrwxrwxrwx    1 root     root            45 Jan  6 00:23 hello8 -> /legato/apps/9d41dd782ea4cecad3de6daa0dc74e55
root@swi-mdm9x28-wp:~# ls -l /legato/systems/current/apps/ | grep hello
lrwxrwxrwx    1 root     root            45 Jan  6 00:23 hello8 -> /legato/apps/9d41dd782ea4cecad3de6daa0dc74e55

I have gotten cgo working so just going to go that route.

Compile Commands

. /opt/swi/SWI9X06Y_03.00.13.00/environment-setup-armv7a-neon-poky-linux-gnueabi 
go generate ./
CC=$CC GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 go build  ./legatoutil.go 
mkapp -w /tmp/pabuild -t wp77xx ./legatoutil.adef

cgo Header

This needs to be in one file in the package calling legato libraries. It can probably also be cleaned up by using the LEGATO_ROOT environment variable.

//go:generate ifgen --output-dir $PWD/ifgen --gen-interface --gen-common-interface --gen-client --gen-common-client --gen-local --gen-messages /var/wp77xx/yocto/legato/interfaces/modemServices/le_mdc.api
//go:generate bash -c "cd ./ifgen; $CC -c *.c -I/var/wp77xx/yocto/legato/framework/include -I/var/wp77xx/yocto/legato/build/wp77xx/framework/include; ar rcs libpalegato.a *.o"

/*
#cgo CFLAGS: -I/var/wp77xx/yocto/legato/framework/include -I/var/wp77xx/yocto/legato/build/wp77xx/framework/include -I${SRCDIR}/ifgen
#cgo LDFLAGS: -L/var/wp77xx/yocto/legato/build/wp77xx/framework/lib/ -llegato -L${SRCDIR}/ifgen -lpalegato
*/
import "C"

adef file

// Disable the sandbox security to make things a little easier.
sandboxed: false

// Put the cross-compiled legacy program in the app's bin directory.
// [x] = make it executable.
bundles:
{
    file:
    {
        [x] $CURDIR/legatoutil /bin/legatoutil
    }
}
extern:
{
    requires:
    {
        le_mdc = $LEGATO_ROOT/interfaces/modemServices/le_mdc.api
    }
}
bindings:
{
     *.le_mdc -> modemService.le_mdc
}