Skip to content
Here is an example to generate qrcode containing vcard data which can be used in business cards.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md

README.md

go-qrcode-vcard-example

Download go-qrcode library so we can use in our code

go get -u github.com/skip2/go-qrcode/...

In our code, we imported the go-qrcode library

import qrcode "github.com/skip2/go-qrcode"
  • Example code to read vcard data from a file and produce a qrcode image

     func main() {
    
        file, err := os.Open("vcard.txt")
        if err != nil {
          log.Fatal(err)
        }
        defer file.Close()
    
        b, err := ioutil.ReadAll(file)
        if err != nil {
          log.Fatal(err)
        }
    
        str := string(b)
        qrFname := "vcard-qr.png"
    
        err = qrcode.WriteFile(str, qrcode.Medium, 256, qrFname)
        if err != nil {
          log.Fatal(err)
        }
    
    }
    

Here is sample data which you can use for vcard.txt

BEGIN:VCARD
VERSION:3.0
N:name
ORG:company
TITLE:title
TEL:123
URL:https://www.website.com
EMAIL:test@email.com
ADR:address1 address2
NOTE:memo
END:VCARD

References

You can’t perform that action at this time.