• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Go实战--golang中生成读取二维码 skip2/go-qrcode和boombuler/barcode

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
                     

生命不止,继续go go go!!!

这里介绍一下,golang如何生成二维码,当然是面向github编程了。

QRCode

百度百科:
QR Code码,是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大、可靠性高、可表示汉字及图象多种文字信息、保密防伪性强等优点。

wiki:
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed 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 efficiently store data; extensions may also be used

skip2/go-qrcode生成二维码

github地址:https://github.com/skip2/go-qrcode
star 211

获取:

go get skip2/go-qrcode
  • 1

生成二维码图片:

package mainimport qrcode "github.com/skip2/go-qrcode"import "fmt"func main() {    err := qrcode.WriteFile("http://blog.csdn.net/wangshubo1989", qrcode.Medium, 256, "qr.png")    if err != nil {        fmt.Println("write error")    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

结果:

boombuler/barcode生成二维码

github地址:https://github.com/boombuler/barcode
star 300

获取:

go get github.com/boombuler/barcode
  • 1

生成二维码图片:

package mainimport (    "image/png"    "os"    "github.com/boombuler/barcode"    "github.com/boombuler/barcode/qr")func main() {    qrCode, _ := qr.Encode("http://blog.csdn.net/wangshubo1989", qr.M, qr.Auto)    qrCode, _ = barcode.Scale(qrCode, 256, 256)    file, _ := os.Create("qr2.png")    defer file.Close()    png.Encode(file, qrCode)}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

结果:

tuotoo/qrcode识别二维码

github地址:https://github.com/tuotoo/qrcode
star 13
获取:

go get github.com/tuotoo/qrcode
  • 1

读取二维码图片:

package mainimport (    "fmt"    "os"    "github.com/tuotoo/qrcode")func main() {    fi, err := os.Open("qrcode.png")    if err != nil {        fmt.Println(err.Error())        return    }    defer fi.Close()    qrmatrix, err := qrcode.Decode(fi)    if err != nil {        fmt.Println(err.Error())        return    }    fmt.Println(qrmatrix.Content)}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

输出:
http://blog.csdn.net/wangshubo1989

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

                     

生命不止,继续go go go!!!

这里介绍一下,golang如何生成二维码,当然是面向github编程了。

QRCode

百度百科:
QR Code码,是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大、可靠性高、可表示汉字及图象多种文字信息、保密防伪性强等优点。

wiki:
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed 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 efficiently store data; extensions may also be used

skip2/go-qrcode生成二维码

github地址:https://github.com/skip2/go-qrcode
star 211

获取:

go get skip2/go-qrcode
  • 1

生成二维码图片:

package mainimport qrcode "github.com/skip2/go-qrcode"import "fmt"func main() {    err := qrcode.WriteFile("http://blog.csdn.net/wangshubo1989", qrcode.Medium, 256, "qr.png")    if err != nil {        fmt.Println("write error")    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

结果:

boombuler/barcode生成二维码

github地址:https://github.com/boombuler/barcode
star 300

获取:

go get github.com/boombuler/barcode
  • 1

生成二维码图片:

package mainimport (    "image/png"    "os"    "github.com/boombuler/barcode"    "github.com/boombuler/barcode/qr")func main() {    qrCode, _ := qr.Encode("http://blog.csdn.net/wangshubo1989", qr.M, qr.Auto)    qrCode, _ = barcode.Scale(qrCode, 256, 256)    file, _ := os.Create("qr2.png")    defer file.Close()    png.Encode(file, qrCode)}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

结果:

tuotoo/qrcode识别二维码

github地址:https://github.com/tuotoo/qrcode
star 13
获取:

go get github.com/tuotoo/qrcode
  • 1

读取二维码图片:

package mainimport (    "fmt"    "os"    "github.com/tuotoo/qrcode")func main() {    fi, err := os.Open("qrcode.png")    if err != nil {        fmt.Println(err.Error())        return    }    defer fi.Close()    qrmatrix, err := qrcode.Decode(fi)    if err != nil {        fmt.Println(err.Error())        return    }    fmt.Println(qrmatrix.Content)}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

输出:
http://blog.csdn.net/wangshubo1989

           

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang新起航!(编译安装go)发布时间:2022-07-10
下一篇:
go语言json转map发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap