1 //go:build go1.16 2 // +build go1.16 3 4 package toml 5 6 import ( 7 "io/fs" 8 ) 9 10 // DecodeFS reads the contents of a file from [fs.FS] and decodes it with 11 // [Decode]. 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 } 20