QR Code码,是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大、可靠性高、可表示汉字及图象多种文字信息、保密防伪性强等优点。
skip2/go-qrcode
地址:https://github.com/skip2/go-qrcode
ackage qrcode implements a QR Code encoder.
A QR Code is a matrix (two-dimensional) barcode. Arbitrary content may be encoded, with URLs being a popular choice :)
Each QR Code contains error recovery information to aid reading damaged or obscured codes. There are four levels of error recovery: Low, medium, high and highest. QR Codes with a higher recovery level are more robust to damage, at the cost of being physically larger.
go get -u github.com/skip2/go-qrcode/...
import (
"fmt"
"github.com/skip2/go-qrcode"
)
func main() {
err := qrcode.WriteFile("hello world", qrcode.Highest, 256, "d://qr.png")
if err!=nil {
fmt.Println(err)
}
}
tuotoo/qrcode
地址:https://github.com/tuotoo/qrcode
go get github.com/tuotoo/qrcode
import (
"os"
"fmt"
"github.com/tuotoo/qrcode"
)
func main() {
file, err := os.Open("d://qr.png")
if err != nil{
fmt.Println(err)
return
}
defer file.Close()
//识别二维码
qr, err := qrcode.Decode(file)
if err != nil{
fmt.Println(err.Error())
return
}
fmt.Println(qr.Content)
}
----------------------------------------------------
hello world
识别刚才生成的二维码图片,输出hello world