Passing parameters to module function

Hello,

I am using the following module for text comparison -> https://github.com/agext/levenshtein

Currently my call looks like this and works:
if levenshtein.Match(rpmname, candidate.Packages[i], nil) >= levmin { levok = true }

I now want to provide parameters to the Match function instead of nil.
But I can’t seem to figure out the syntax to do that. I have tried all types of notations with curly brackets, normal brackets, defining a struct with the proper names, etc. but I am obviously lacking something here.

Any help would be appreciated!

Cheers,
Lordy

1 Like

Usually you can find some hints in tests. For not nil params:

NewParams().MaxCost(6)

1 Like

Doing this, I run into the following error:

undefined: NewParams

Any ideas?

1 Like

Of course, it’s function from external package so youu must call it via package_name.function_name syntax :wink:
So levenshtein.NewParams()

1 Like

Thanks, it was late and I am still stuck a bit in the Perl mindset where the module name is not used as a prefix. I seem to trigger some out of range bugs with this:

      	var myparams = levenshtein.NewParams()
     	myparams.MinScore(0.92)
     	spew.Dump(myparams)
    	if levenshtein.Match(rpmname, candidate.Packages[i], myparams) >= levmin { levok = true }

I have opened an issue on GitHub for this.
Thanks for your help!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.