Skip to content

panic: runtime error: index out of range #3

Closed
@stevemeier

Description

Hello,

please excuse if this is not an issue with your code but as a beginner in Golang it seems to me like it could be.

Here is the sample code I run:

package main

import "fmt"
import "github.com/davecgh/go-spew/spew"
import "github.com/agext/levenshtein"

func main () {
	var myparams = levenshtein.NewParams()
	myparams.MinScore(0.92)
	spew.Dump(myparams)

	fmt.Println(levenshtein.Match(`foo`, `foo`, myparams))
	fmt.Println(levenshtein.Match(`foo`, `bar`, myparams))
	fmt.Println(levenshtein.Match(`NetworkManager-glib-0.8.1-5.el6_0.1.i686.rpm`, `gdm-plugin-fingerprint-2.30.4-39.el6.i686.rpm`, myparams))
}

It produces the following output:

(*levenshtein.Params)(0xc000094100)({
 insCost: (int) 1,
 subCost: (int) 1,
 delCost: (int) 1,
 maxCost: (int) 0,
 minScore: (float64) 0.92,
 bonusPrefix: (int) 4,
 bonusScale: (float64) 0.1,
 bonusThreshold: (float64) 0.7
})
1
0
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/agext/levenshtein.Calculate(0xc0000ca000, 0x24, 0x2c, 0xc0000cc000, 0x23, 0x30, 0x5, 0x1, 0x1, 0x1, ...)
	/Users/smeier/go/src/github.com/agext/levenshtein/levenshtein.go:112 +0x8ba
github.com/agext/levenshtein.Match(0x11036f6, 0x2c, 0x11037ff, 0x2d, 0xc000094100, 0x2)
	/Users/smeier/go/src/github.com/agext/levenshtein/levenshtein.go:272 +0x1a8
main.main()
	/Users/smeier/Documents/grabbag/levenshtein_bug.go:14 +0x271
exit status 2

I am running go version go1.12.5 darwin/amd64.

Any help or comments are appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions