added example

This commit is contained in:
boombuler 2013-12-12 21:02:54 +01:00
parent 9fb741398c
commit a4e3d9eecf
1 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,10 @@
package qr package qr
import ( import (
"fmt"
"github.com/boombuler/barcode"
"image/png"
"os"
"testing" "testing"
) )
@ -52,3 +56,20 @@ func Test_Encode(t *testing.T) {
} }
} }
} }
func ExampleEncode() {
f, _ := os.Create("qrcode.png")
defer f.Close()
qrcode, err := Encode("hello world", L, Auto)
if err != nil {
fmt.Println(err)
} else {
qrcode, err = barcode.Scale(qrcode, 100, 100)
if err != nil {
fmt.Println(err)
} else {
png.Encode(f, qrcode)
}
}
}