package zhios_tool_qrcode import ( "image" _ "image/jpeg" _ "image/png" "os" "github.com/makiuchi-d/gozxing" "github.com/makiuchi-d/gozxing/qrcode" ) func DecodeFile(fi string) (string, error) { file, err := os.Open(fi) if err != nil { return "", err } img, _, err := image.Decode(file) if err != nil { return "", err } // prepare BinaryBitmap bmp, err := gozxing.NewBinaryBitmapFromImage(img) if err != nil { return "", err } // decode image result, err := qrcode.NewQRCodeReader().Decode(bmp, nil) if err != nil { return "", err } return result.String(), nil }