2022-11-11 11:22:50 +01:00
|
|
|
//go:build go1.16
|
2021-12-02 17:54:14 +01:00
|
|
|
// +build go1.16
|
|
|
|
|
|
|
|
package toml
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/fs"
|
|
|
|
)
|
|
|
|
|
2022-11-11 11:22:50 +01:00
|
|
|
// DecodeFS reads the contents of a file from [fs.FS] and decodes it with
|
|
|
|
// [Decode].
|
2021-12-02 17:54:14 +01:00
|
|
|
func DecodeFS(fsys fs.FS, path string, v interface{}) (MetaData, error) {
|
|
|
|
fp, err := fsys.Open(path)
|
|
|
|
if err != nil {
|
|
|
|
return MetaData{}, err
|
|
|
|
}
|
|
|
|
defer fp.Close()
|
|
|
|
return NewDecoder(fp).Decode(v)
|
|
|
|
}
|