qrt

package module
v0.0.0-...-5559caa Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2014 License: BSD-2-Clause Imports: 2 Imported by: 3

README

go.qrt

GoDoc Generate QR code's for in your terminal.

go.qrt generates a QR code based on UTF-8 characters. This allow you to display a QR code in your terminal

Install

go get github.com/GeertJohan/go.qrt

Usage example

package main

import (
	"fmt"
	"github.com/GeertJohan/go.qrt"
)

func main() {
	str, err := qrt.Generate("some example text")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Print(str)
}

Documentation

For more information about the options you can use for QR generation, please check the documentation at godoc.org/github.com/GeertJohan/go.qrt

License

This project is licensed under a Simplified BSD license. Please read the LICENSE file.

Attribution

This package imports and uses code.google.com/p/rsc/qr, a QR generation package by Russ Cox.

Screenshot

QR code in terminal

Depending on your terminal and font you may need to scan the QR code under an angle to make it appear square for the scanner.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	UseSGR: true,
	Level:  M,
}

DefaultConfig is used by the Generate function You can change it's values, or create a Config instance of your own.

Functions

func Generate

func Generate(text string) (string, error)

Generate a text string to a QR code, which you can write to a terminal or file. Generate is a shorthand for DefaultConfig.Generate(text)

Types

type Config

type Config struct {
	// UseSGR, when true, Generate() uses Select Graphic Rendition (github.com/foize/go.sgr) to force correct colors in the terminal (black/white)
	// You should disable this when writing the result to a file
	UseSGR bool

	// Level indicates the required redudancy level for the generated QR's
	// You can keep the redundancy value low because screens are pretty bright and clean.... Or well, they should be.
	Level Level
}

Config hold all paramters that can be set with this library

func (*Config) Generate

func (c *Config) Generate(text string) (string, error)

Generate a text string to a QR code, which you can write to a terminal or file.

type Level

type Level int

A Level denotes a QR error correction level. From least to most tolerant of errors, they are L, M, Q, H.

const (
	L Level = iota // 20% redundant
	M              // 38% redundant
	Q              // 55% redundant
	H              // 65% redundant
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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