Created
October 5, 2017 00:48
-
-
Save campoy/f5e54baddcf3923e54171d29549be9ec to your computer and use it in GitHub Desktop.
A simple program to print QR Codes on your terminal
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
// 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