sophuwu.site > goauth
uwuwuwu
sophuwu sophie@skisiel.com
Wed, 15 May 2024 15:14:16 +0200
commit

e9cd40758658c143331bc8205639d493f58b4024

parent

d9635e62e183d911c8e591dfc52040ffd1b4781b

1 files changed, 10 insertions(+), 7 deletions(-)

jump to
M test/main.goqrcode.go

@@ -1,11 +1,18 @@

-package main +package goauth + +/* + * This file is to turn strings into unicode or html qr codes. + * Author: sophuwu <sophie@skisiel.com> + * Feel free to use this code in any way you want. + * Just call QR("string", header bool, html bool) to get a qr code. + * The header will display the string above the qr code. + */ import ( "fmt" "github.com/boombuler/barcode/qr" "image" "image/color" - "os" "strings" )

@@ -101,7 +108,7 @@ }

return lines } -func encodeqr(s string, header bool, html bool) (string, error) { +func QR(s string, header bool, html bool) (string, error) { bar, err := qr.Encode(s, qr.L, qr.Auto) if err != nil { return "", err

@@ -126,7 +133,3 @@ }

output += fmt.Sprintln(qrstr(bar, html)) return output, nil } - -func main() { - fmt.Println(encodeqr(strings.Join(os.Args[1:], " "), true, false)) -}