feat: added QR code functionality

This commit is contained in:
Andrej Zavgorodnij 2020-07-22 16:01:36 +03:00
parent 2833f5b317
commit 289b0d3ac5
1 changed files with 5 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"os"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
@ -18,6 +19,10 @@ import (
const tmpImageFile = "/tmp/qr.png"
func ShowQR(data string) error {
defer func() {
_ = os.Remove(tmpImageFile)
}()
err := encoder.WriteFile(data, encoder.Medium, 512, tmpImageFile)
if err != nil {
return fmt.Errorf("failed to encode the data: %w", err)