Golang filepath throws error in K6 extension

I am using IMX Golang SDK to build a K6 extension to interact with blockchain.
Reference: GitHub - immutable/imx-core-sdk-golang: The Immutable Core SDK Golang provides convenient access to the Immutable APIs and Ethereum contract methods for applications integrating with ImmutableX platform.

The SDK generates the L2 Stark key fine when executed independently. However it throws following error, when incorporated in a K6 extension.

INFO[0007] 2022/11/14 12:00:24 error in Generating Stark Private Key: open github.com\immutable\imx-core-sdk-golang@v0.2.2\imx\signers\stark/pedersen_params.json: The system cannot find the path specified.
ERRO[0007] panic: error in Generating Stark Private Key: open github.com\immutable\imx-core-sdk-golang@v0.2.2\imx\signers\stark/pedersen_params.json: The system cannot find the path specified.

The file path separator looks inconsistent to me, when working through extension. It is constructed in following file.

Relevant function which throws error:

func loadCurve() (*caigo.StarkCurve, error) {
	dir, err := currentDirname()
	if err != nil {
		return nil, err
	}
	pedersenParamsFilePath := path.Join(dir, "pedersen_params.json")
	sc, err := caigo.SC(caigo.WithConstants(pedersenParamsFilePath))
	if err != nil {
		return nil, err
	}
	return &sc, nil
}

Any suggestion on how to get rid of this error when working with K6?

Hi there,

this is really a question for the maintainers of that SDK.

I’m not familiar with their codebase, but it seems that currentDirName() is resolving to the module path of the function that calls it, judging by the use of runtime.Caller(1), and it’s creating that key file there. This seems like the wrong thing to do to me, but you should contact them to confirm. There’s nothing you can do on the xk6 side to fix this.

Good luck!

Thanks, it was fixed by the maintainer of that SDK.