7558655458
I have put too much code into the same files. Also, I put everything into the same package: main. This package is only meant for executables. Therefore, I have refactored my code to use multiple packages. These packages also guarantee separation of concerns since Golang doesn't allow cyclic imports.
17 lines
272 B
Go
17 lines
272 B
Go
package lib
|
|
|
|
import (
|
|
"encoding/base64"
|
|
|
|
"github.com/skip2/go-qrcode"
|
|
)
|
|
|
|
func ToQR(s string) (string, error) {
|
|
png, err := qrcode.Encode(s, qrcode.Medium, 256)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
qr := base64.StdEncoding.EncodeToString([]byte(png))
|
|
return qr, nil
|
|
}
|