Skip to content

Instantly share code, notes, and snippets.

@campoy
Created October 5, 2017 00:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save campoy/f5e54baddcf3923e54171d29549be9ec to your computer and use it in GitHub Desktop.
Save campoy/f5e54baddcf3923e54171d29549be9ec to your computer and use it in GitHub Desktop.
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