This is a small repository showing how to generate a QR code with an optional watermark in Go.
Credits to Matthew Setter, his blogpost https://www.twilio.com/blog/generate-qr-code-with-go explains this code. Note: the blogpost mentions content=
instead of url=
to use for the content you want to encode in the QR code.
go run main.go
Test if the API works
curl -i -X POST http://localhost:8080/generate
curl -X POST \
--form "size=256" \
--form "url=https://fashionunited.com" \
--output data/qrcode.png \
http://localhost:8080/generate
Put a list of urls in example.txt. Make sure there is a newline at the end.
./generate.sh
gcloud config set project PROJECT_ID
gcloud run deploy --region=europe-west1 --allow-unauthenticated
gcloud run services describe go-qr-code-generator --platform managed --region europe-west1 --format 'value(status.url)'
curl -X POST \
--form "size=256" \
--form "url=https://fashionunited.nl/modevacatures/werken-bij/ray-ban-vacatures/search/in/rotterdam" \
--output data/ray-ban-rotterdam.png \
https://go-qr-code-generator-XXXXXXXXXX.a.run.app/generate
-
Set Project Id:
export GOOGLE_CLOUD_PROJECT=<GCP_PROJECT_ID> # in this case: export GOOGLE_CLOUD_PROJECT=go-qr-code-generator