package main
import (
"log"
"bytes"
"image"
"io/ioutil"
_ "image/jpeg"
_ "image/png"
"github.com/liyue201/goqr"
qrcode "github.com/skip2/go-qrcode"
)
func main() {
p := "/tmp/test-goqr.png"
err := qrcode.WriteFile(`-----BEGIN PGP MESSAGE-----
wy4ECQMIlEOR6t1Wvp1guIRRXN87HQ3UOlSurE3gyiQslGraKi8kZYypMiygs0R8
0uAB5GzHuQ8nkg6uGv3tZ6/sdTDh+WTga+Dc4Yk34JTiRWqEv+DW5TllSJSMPjw6
YPpzIAwihrjG+cpfuF1OhrJwy8duwSR54DfkiHu7ymylwCw9lCejbU1OHODP4ogk
4CPgDuS/gfaOnv6Rb4MzV7/CnFeS4neA2yfhUWoA
=mD6l
-----END PGP MESSAGE-----`, qrcode.Medium, 256, p)
if err != nil {
log.Fatal(err)
}
imgdata, err := ioutil.ReadFile(p)
if err != nil {
log.Fatal(err)
}
img, _, err := image.Decode(bytes.NewReader(imgdata))
if err != nil {
log.Fatal(err)
}
_, err = goqr.Recognize(img)
if err != nil {
log.Fatal(err)
}
}
panic: runtime error: index out of range [3] with length 2
goroutine 1 [running]:
github.com/liyue201/goqr.alphaTuple(0xc0000161c0, 0xc0003c9818, 0xb, 0x2, 0xfd)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/decoding.go:580 +0x1fa
github.com/liyue201/goqr.decodeAlpha(0xc0000161c0, 0xc0003c9818, 0x2, 0xc0003c97b0)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/decoding.go:598 +0xad
github.com/liyue201/goqr.decodePayload(0xc0000161c0, 0xc0003c9818, 0x0, 0x0)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/decoding.go:695 +0x8e
github.com/liyue201/goqr.decode(0xc0003d3000, 0xc0000161c0, 0x0, 0x629290)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/qrcode.go:141 +0x16d
github.com/liyue201/goqr.(*recognizer).Decode(0xc0002fc000, 0x0, 0x0, 0x629290, 0xc0001bf42c)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/recognizer.go:106 +0xb9
github.com/liyue201/goqr.Recognize(0x53daa0, 0xc000052420, 0x53daa0, 0xc000052420, 0x518e4d, 0x3, 0x0)
/tmp/gopath044694003/pkg/mod/github.com/liyue201/[email protected]/recognition.go:54 +0x2e2
main.main()
/tmp/sandbox177494500/prog.go:40 +0x1fa