tucnak / telebot

Telebot is a Telegram bot framework in Go.
MIT License
4.04k stars 469 forks source link

Allow initialisation from io.Reader #610

Closed rusq closed 1 year ago

rusq commented 1 year ago

Problem

layout package expects the yaml file to be available on disk. With embedding, it could be convenient to store the yaml on an embedded filesystem, or embed as a string at compile-time.

Proposed Solution

This allows to use the embedded layout.yaml file, i.e.:

//go:embed layout.yaml
var layoutYAML string

func foo() {
    //...
    l, err := layout.FromReader(strings.NewReader(layoutYAML))
    if err != nil {
        // handle err
    }
    // use layout
    // ...
}
rusq commented 1 year ago

As I experiment with layout, I think it's better to add the support for fs.FS. I'll create a PR when I have something, experimenting with layout ATM. Would be interesting to know your thoughts @demget .