Skip to content

erencanucarr/goQR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goQR

A lightweight QR code generator for Go with zero dependencies. Simple, fast, and pure Go.

Features

  • No external dependencies
  • Standard QR code generation (version 1-40)
  • Error correction (L, M, Q, H)
  • Simple API

Installation

go get github.com/erencanucarr/goQR

Usage

package main

import (
    "fmt"
    "log"
    "github.com/erencanucarr/goQR"
)

func main() {
    qr, err := goQR.GenerateQR("Hello, World!", goQR.Low)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(qr.ToString())
}

API

  • GenerateQR(data string, errorLevel ErrorCorrectionLevel) (*QRCode, error)
  • QRCode.ToString() string (prints QR code to terminal)
  • QRCode.GetMatrix() [][]bool (raw matrix)
  • QRCode.GetVersion() int
  • QRCode.GetErrorLevel() ErrorCorrectionLevel

License

MIT

Technical Details

QR Code Algorithm

This library implements the following steps of the QR code algorithm:

  1. Data Encoding: Convert data to binary format
  2. Error Correction: Generate error correction codes using Reed-Solomon coding
  3. Matrix Creation: Create QR code matrix
  4. Finder Pattern's: Add finder patterns to QR code corners
  5. Alignment Pattern's: Add alignment patterns
  6. Timing Pattern's: Add timing patterns
  7. Format Information: Add error correction level and masking information
  8. Masking: Apply masking to improve QR code readability

Galois Field Arithmetic

This library uses GF(2^8) Galois field arithmetic for Reed-Solomon error correction:

  • Primitive polynomial: x^8 + x^4 + x^3 + x^2 + 1
  • Field size: 256
  • Generator polynomials: Pre-calculated for different error correction levels

Testing

To test this library:

go test

For benchmark tests:

go test -bench=.

Examples

For more examples, check out the example/ directory:

cd example
go run main.go

Performance

This library uses optimized algorithms:

  • Small data (< 100 characters): ~1ms
  • Medium data (100-500 characters): ~5ms
  • Large data (> 500 characters): ~10-50ms

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push your changes (git push origin feature/amazing-feature)
  5. Create a pull request

License

This project is licensed under the MIT License. See LICENSE for details.

Version History

  • v1.0.0: Initial version - Basic QR code generation features

Contact

Thanks

This library was developed following the QR code standard (ISO/IEC 18004). No third-party libraries were used.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages