Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kfatehi/go-qrcode-memwriter
https://github.com/kfatehi/go-qrcode-memwriter
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kfatehi/go-qrcode-memwriter
- Owner: kfatehi
- Created: 2022-09-08T06:37:00.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-10T01:06:12.000Z (over 2 years ago)
- Last Synced: 2025-01-03T19:17:29.609Z (23 days ago)
- Language: Go
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This module wraps [go-qrcode](github.com/yeqown/go-qrcode)'s [standard writer](https://github.com/yeqown/go-qrcode/tree/main/writer/standard) replacing the call to `os` with [afero](https://github.com/spf13/afero#memory-backed-storage) (A FileSystem Abstraction System for Go) for those of us that don't need to write to an actual file.
Example
qr.go
```go
package mainimport (
"fmt"qrcode_memwriter "github.com/kfatehi/go-qrcode-memwriter"
"github.com/spf13/afero"
"github.com/yeqown/go-qrcode/v2"
"github.com/yeqown/go-qrcode/writer/standard"
)func generate_qr(AppFs afero.Fs, path string, content string) (string, error) {
qrc, err := qrcode.New(content)
if err != nil {
fmt.Printf("could not generate QRCode: %v", err)
return "", err
}w, err := qrcode_memwriter.New(AppFs, path, standard.WithQRWidth(4))
if err != nil {
fmt.Printf("standard.New failed: %v", err)
return "", err
}if err = qrc.Save(w); err != nil {
fmt.Printf("could not save image: %v", err)
return "", err
}return path, nil
}
```