blog/go/qrcode/main.go

25 lines
417 B
Go
Raw Normal View History

2022-11-04 11:35:20 +08:00
package main
import (
"image/color"
"log"
"os"
"github.com/skip2/go-qrcode"
)
func main(){
code, err := qrcode.New("http://weixin.qq.com/q/02vEhthpJ1fqD1mfbvxzcy", qrcode.High)
if err != nil {
log.Fatal(err)
}
code.BackgroundColor = color.Transparent
data, err := code.PNG(256)
if err != nil {
log.Fatal(err)
}
err = os.WriteFile("tmp.png", data, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}