Skip to content

Instantly share code, notes, and snippets.

@campoy
Created Oct 5, 2017
Embed
What would you like to do?
A simple program to print QR Codes on your terminal
// Copyright 2017 Google Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to writing, software distributed
// under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"fmt"
"log"
qr "github.com/skip2/go-qrcode"
)
func main() {
c, err := qr.New("http://justforfunc.com", qr.Highest)
if err != nil {
log.Fatal(err)
}
for _, row := range c.Bitmap() {
for _, cell := range row {
if cell {
fmt.Printf("\033[40m \033[0m")
} else {
fmt.Printf("\033[47m \033[0m")
}
}
fmt.Println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment