error mgt in qr write
This commit is contained in:
@ -53,7 +53,6 @@ func (contact *ContactCard) Compress() ([]byte, error) {
|
||||
if err := gz.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(b.Bytes())
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
@ -143,13 +142,13 @@ func (contact *ContactCard) WritePng(filename string) {
|
||||
|
||||
}
|
||||
|
||||
func (Contact *ContactCard) WriteQr(filename string) {
|
||||
func (Contact *ContactCard) WriteQr(filename string) error {
|
||||
//jsonContact, _ := json.Marshal(Contact)
|
||||
jsonContact, _ := Contact.Compress()
|
||||
qwriter := qrcode.NewQRCodeWriter()
|
||||
code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return err
|
||||
}
|
||||
file, _ := os.Create(filename)
|
||||
defer file.Close()
|
||||
@ -157,7 +156,7 @@ func (Contact *ContactCard) WriteQr(filename string) {
|
||||
// *BitMatrix implements the image.Image interface,
|
||||
// so it is able to be passed to png.Encode directly.
|
||||
_ = png.Encode(file, code)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReadQr(Filename string) ContactCard {
|
||||
|
Reference in New Issue
Block a user