Skip to content

Instantly share code, notes, and snippets.

@csrgxtu
Created April 15, 2016 00:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save csrgxtu/b415c269ee3bcc1e7e8ddab30d173f01 to your computer and use it in GitHub Desktop.
Save csrgxtu/b415c269ee3bcc1e7e8ddab30d173f01 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/kiktomo/goqr"
"image/png"
"os"
)
func main() {
// "0123456789" -> Numeric mode
// "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:" -> Alphanumeric mode
// "HELLO WORLD" -> Alphanumeric mode (upper-case only)
// "Hello world" -> 8BitByte mode
txt := "HELLO WORLD"
// QRcode version:7
// version := 0 (Auto)
version := 7
// QRcode error correction level: "M"
// eclevel := 0 (Auto)
eclevel := goqr.ECLevelM
// Encode() returns image.Image
qr, err := goqr.Encode(txt, version, eclevel)
if err != nil {
return
}
// png file output
f, _ := os.Create("./qrcode.png")
defer f.Close()
png.Encode(f, qr)
}
@csrgxtu
Copy link
Author

csrgxtu commented Apr 15, 2016

package main

import qrcode "github.com/skip2/go-qrcode"
import "fmt"

func main() {
    err := qrcode.WriteFile("https://dev-article.beautifulreading.com/static/html/login.html", qrcode.Medium, 256, "qr.png")
  if err != nil {
    fmt.Print(err)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment