qrencode-go

module
v0.0.0-...-ad8353b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2017 License: LGPL-3.0

README

QR encoder in Go based on the ZXing encoder (http://code.google.com/p/zxing/).

GoDoc Build Status

I was surprised that I couldn't find a QR encoder in Go, especially since the example at http://golang.org/doc/effective_go.html#web_server is a QR code generator, though the QR encoding is done by an external Google service in the example.

Example

package main

import (
	"bytes"
	"image/png"
	"os"

	"github.com/qpliu/qrencode-go/qrencode"
)

func main() {
	var buf bytes.Buffer
	for i, arg := range os.Args {
		if i > 1 {
			if err := buf.WriteByte(' '); err != nil {
				panic(err)
			}
		}
		if i > 0 {
			if _, err := buf.WriteString(arg); err != nil {
				panic(err)
			}
		}
	}
	grid, err := qrencode.Encode(buf.String(), qrencode.ECLevelQ)
	if err != nil {
		panic(err)
	}
	png.Encode(os.Stdout, grid.Image(8))
}

Directories

Path Synopsis
Package qrencode provides functions to generate QR codes.
Package qrencode provides functions to generate QR codes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL