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