/
View dependency graph
Depends on
- dh-golang (dh-sequence-golang)
- dpkg (dpkg-build-api)
- golang-defaults (golang-any)
- golang-github-fogleman-gg (golang-github-fogleman-gg-dev)
- golang-github-mattn-go-runewidth (golang-github-mattn-go-runewidth-dev)
- golang-github-nsf-termbox-go (golang-github-nsf-termbox-go-dev)
- golang-github-pkg-errors (golang-github-pkg-errors-dev)
- golang-github-urfave-cli (golang-github-urfave-cli-dev)
- golang-github-urfave-cli-v2 (golang-github-urfave-cli-v2-dev)
- golang-github-yeqown-reedsolomon (golang-github-yeqown-reedsolomon-dev)
- golang-golang-x-image (golang-golang-x-image-dev)
- golang-golang-x-text (golang-golang-x-text-dev)
- golang-testify (golang-github-stretchr-testify-dev)
- help2man (help2man)
- debhelper-compat
README (full)
go-qrcode
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed in 1994 for the automotive industry in Japan. A barcode is a machine-readable optical label that contains information about the item to which it is attached. A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to store data efficiently; extensions may also be used
Features
-
Normally generate QR code across
version 1toversion 40. - Automatically analyze QR version by source text.
-
Specifying cell shape allowably with
WithCustomShape,WithCircleShape(default isrectangle) -
Specifying output file's format with
WithBuiltinImageEncoder,WithCustomImageEncoder(default isJPEG) - Not only shape of cell, but also color of QR Code background and foreground color.
-
WithLogoImage,WithLogoImageFilePNG,WithLogoImageFileJPEGhelp you add an icon at the central of QR Code. -
WithBorderWidthallows to specify any width of 4 sides around the qrcode. -
WebAssemblysupport, check out the Example and README for more detail. - support Halftone QR Codes, check out the Example.
Install
go get -u github.com/yeqown/go-qrcode/v2
Quick Start
link to CODE
package main
import (
"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
)
func main() {
qrc, err := qrcode.New("https://github.com/yeqown/go-qrcode")
if err != nil {
fmt.Printf("could not generate QRCode: %v", err)
return
}
w, err := standard.New("../assets/repo-qrcode.jpeg")
if err != nil {
fmt.Printf("standard.New failed: %v", err)
return
}
// save file
if err = qrc.Save(w); err != nil {
fmt.Printf("could not save image: %v", err)
}
}
Options
const (
// EncModeNone mode ...
EncModeNone encMode = 1 << iota
// EncModeNumeric mode ...
EncModeNumeric
// EncModeAlphanumeric mode ...
EncModeAlphanumeric
// EncModeByte mode ...
EncModeByte
// EncModeJP mode ...
EncModeJP
)
// WithEncodingMode sets the encoding mode.
func WithEncodingMode(mode encMode) EncodeOption {}
const (
// ErrorCorrectionLow :Level L: 7% error recovery.
ErrorCorrectionLow ecLevel = iota + 1
// ErrorCorrectionMedium :Level M: 15% error recovery. Good default choice.
ErrorCorrectionMedium
// ErrorCorrectionQuart :Level Q: 25% error recovery.
ErrorCorrectionQuart
// ErrorCorrectionHighest :Level H: 30% error recovery.
ErrorCorrectionHighest
)
// WithErrorCorrectionLevel sets the error correction level.
func WithErrorCorrectionLevel(ecLevel ecLevel) EncodeOption {}
following are some shots:
Built-in Writers
- Standard Writer, prints QRCode into file and stream
- Terminal Writer, prints QRCode into terminal
- File Writer, prints QRCode into files
- Compressed Writer, It's generated on a very small scale
Of course, you can also code your own writer, just implement Writer interface.
Migrating from v1
go-qrcode.v2 is a major upgrade from v1, and it is not backward compatible. v2 redesigned
the API, and it is more flexible and powerful. Features are split into different modules (according to functionality).
- github.com/yeqown/go-qrcode/v2 core
- github.com/yeqown/go-qrcode/writer/standard writer/imageFile
- github.com/yeqown/go-qrcode/writer/terminal writer/terminal
Check example/migrating-from-v1 for more details.
Links
| dir | .github/ |
| dir | .issues/ |
| dir | assets/ |
| dir | cmd/ |
| dir | debian/ |
| dir | example/ |
| dir | writer/ |
| file | .gitignore |
| file | LICENSE |
| file | Makefile |
| file | README.md |
| file | debug.go |
| file | encoder.go |
| file | encoder_option.go |
| file | encoder_test.go |
| file | go.mod |
| file | go.sum |
| file | go.work |
| file | go.work.sum |
| file | kmp_variant.go |
| file | kmp_variant_test.go |
| file | mask.go |
| file | mask_evaluation.go |
| file | mask_evaluation_test.go |
| file | mask_test.go |
| file | matrix.go |
| file | matrix_test.go |
| file | matrix_type.go |
| file | matrix_type_test.go |
| file | qrcode.go |
| file | qrcode_test.go |
| file | utilities.go |
| file | utilities_test.go |
| file | version.go |
| file | version_cfg.go |
| file | version_test.go |
| file | writer.go |