Created
February 16, 2021 11:13
-
-
Save r10r/a2450c2aeb8858edd60eb963803b8f71 to your computer and use it in GitHub Desktop.
Generate simple QRCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
qrcode "github.com/skip2/go-qrcode" | |
"io/ioutil" | |
"os" | |
) | |
func main() { | |
/* | |
The maximum capacity of a QR Code varies according to the content encoded and the error recovery level. The maximum capacity is 2,953 bytes, 4,296 alphanumeric characters, 7,089 numeric digits, or a combination of these. | |
*/ | |
data, err := ioutil.ReadAll(os.Stdin) | |
if err != nil { | |
panic(err) | |
} | |
var png []byte | |
png, err = qrcode.Encode(string(data), qrcode.Medium, 256) | |
if err != nil { | |
panic(err) | |
} | |
_, err = os.Stdout.Write(png) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment