|
|
@@ -1,6 +1,10 @@
|
|
|
package qr
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/boombuler/barcode"
|
|
|
+ "image/png"
|
|
|
+ "os"
|
|
|
"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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|