|
@@ -1,17 +1,24 @@
|
|
|
package qr
|
|
|
|
|
|
import (
|
|
|
+ "log"
|
|
|
+ "os"
|
|
|
"os/exec"
|
|
|
+ "path/filepath"
|
|
|
|
|
|
"github.com/skip2/go-qrcode"
|
|
|
)
|
|
|
|
|
|
// RenderString as a QR code
|
|
|
func RenderString(s string) {
|
|
|
- err := qrcode.WriteFile(s, qrcode.Medium, 200, "tmp.png")
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
+ dir, err1 := filepath.Abs(filepath.Dir(os.Args[0]))
|
|
|
+ if err1 != nil {
|
|
|
+ log.Fatal(err1)
|
|
|
}
|
|
|
- cmd:=exec.Command("rundll32.exe", "url.dll,FileProtocolHandler", "tmp.png")
|
|
|
+ err2 := qrcode.WriteFile(s, qrcode.Medium, 200, dir+"/tmp.png")
|
|
|
+ if err2 != nil {
|
|
|
+ panic(err2)
|
|
|
+ }
|
|
|
+ cmd := exec.Command("rundll32.exe", "url.dll,FileProtocolHandler", dir+"/tmp.png")
|
|
|
cmd.Start()
|
|
|
}
|