added example
This commit is contained in:
parent
9fb741398c
commit
a4e3d9eecf
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue