A lightweight QR code generator for Go with zero dependencies. Simple, fast, and pure Go.
- No external dependencies
- Standard QR code generation (version 1-40)
- Error correction (L, M, Q, H)
- Simple API
go get github.com/erencanucarr/goQRpackage 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())
}GenerateQR(data string, errorLevel ErrorCorrectionLevel) (*QRCode, error)QRCode.ToString() string(prints QR code to terminal)QRCode.GetMatrix() [][]bool(raw matrix)QRCode.GetVersion() intQRCode.GetErrorLevel() ErrorCorrectionLevel
MIT
This library implements the following steps of the QR code algorithm:
- Data Encoding: Convert data to binary format
- Error Correction: Generate error correction codes using Reed-Solomon coding
- Matrix Creation: Create QR code matrix
- Finder Pattern's: Add finder patterns to QR code corners
- Alignment Pattern's: Add alignment patterns
- Timing Pattern's: Add timing patterns
- Format Information: Add error correction level and masking information
- Masking: Apply masking to improve QR code readability
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
To test this library:
go testFor benchmark tests:
go test -bench=.For more examples, check out the example/ directory:
cd example
go run main.goThis library uses optimized algorithms:
- Small data (< 100 characters): ~1ms
- Medium data (100-500 characters): ~5ms
- Large data (> 500 characters): ~10-50ms
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push your changes (
git push origin feature/amazing-feature) - Create a pull request
This project is licensed under the MIT License. See LICENSE for details.
- v1.0.0: Initial version - Basic QR code generation features
- GitHub: @erencanucarr
- Project: goQR
This library was developed following the QR code standard (ISO/IEC 18004). No third-party libraries were used.