You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
399 B

  1. //go:build go1.16
  2. // +build go1.16
  3. package toml
  4. import (
  5. "io/fs"
  6. )
  7. // DecodeFS is just like Decode, except it will automatically read the contents
  8. // of the file at `path` from a fs.FS instance.
  9. func DecodeFS(fsys fs.FS, path string, v interface{}) (MetaData, error) {
  10. fp, err := fsys.Open(path)
  11. if err != nil {
  12. return MetaData{}, err
  13. }
  14. defer fp.Close()
  15. return NewDecoder(fp).Decode(v)
  16. }